Programmatically creating pages

In reference to my previous post - as I’m importing content into
Radiant from Wordpress, how do I go about setting the created_by to a
user? Every time I set the value, it’s always NULL that ends up in the
table (although updated_by is working just fine)

Is there a hook in the code that I haven’t spotted that’s doing this?

On 9 Dec 2010, at 16:13, Neil wrote:

In reference to my previous post - as I’m importing content into Radiant from
Wordpress, how do I go about setting the created_by to a user? Every time I set
the value, it’s always NULL that ends up in the table (although updated_by is
working just fine)

Is there a hook in the code that I haven’t spotted that’s doing this?

Yes, probably. UserActionObserver sets created_by in a before_create
filter that isn’t visible from the Page class itself. In the console or
a rake task there is no current user, so it nulls any existing
association.

Are you scripting the import? In that case you just need to set
UserActionObserver.current_user to a user object before you create the
pages. If you’re assigning a different user to each page, the easiest
way is just to do it in another operation after creation.

And re:

The /blog part I can deal with, but the day is causing me issues. Is
there any way I can get Radiant to work without the day part in the
route?

I don’t use the archive extension - which is responsible for your urls
here - but looking at the code, the url format will be quite hard to
change. It’s spelt out in several places and used to support the
day/month/year views. Perhaps an easier option would be to print the old
and new paths as the posts are imported and use that output to create
many specific rewrite rules rather than one general one?

best,

will