I'm resurrecting an old thread just before starting to look at it
myself. I'm likely to work on a project where it will be needed to
update a large number of pages. I think it may be possible to dump the
content out to a bunch of files from where it should be possible to pick
up the pages, add the usual stuff and update the pages to a Radiant site
using a script.
Is there anyone doing so using the script below or something similar?
Would it be possible to share?
I've never used script/runner with a live site but I'm willing to look
at the relevant stuff in the Rails world to make that happen. But I'm
just starting to wonder how to keep this site scalable (since it
involves the migration of about 7 books from PDF to Radiant) with a
bunch of relatively standard things to be included on each page.
Thanks,
Mohit.
12/19/2007 | 11:58 PM.
Sean Cribbs wrote:
> Saji,
>
> You might try using "create" instead of "build". In that case, it could
> look like this:
>
> parent = Page.find_by_url('/services/news')
> child = parent.children.create(:title => "Floods", :breadcrumb =>
> "Floods", :slug => "floods")
> child.parts.create(:name => "body", :content => "This is a page for
> flood news")
>
> Keep in mind that create and build might not work if the collection is
> empty or the original object is unsaved [1]. Your other alternative is
> to build the objects manually, then push it into the collection:
>
> parent = Page.find_by_url('/services/news')
> child = Page.new(:title => "Floods", :breadcrumb => "Floods", :slug =>
> "floods")
> part = PagePart.new(:name => "body", :content => "This is a page for
> flood news")
> parent.children << child
> child.parts << part
>
> Also note in your second snippet that your part needs a name.
>
> Sean
>
> [1]
> http://api.rubyonrails.org/classes/ActiveRecord/Associations/ClassMethods.html#M000642
>
> (if I'm interpreting the doc correctly)
>
> Saji Njarackalazhikam Hameed wrote:
>
>> Dear All,
>>
>> Thanks for the kind lessons on how to add a page using script/runner. I
>> have the following working script to create such a new page:
>>
>> # ------ start of script to add a new page ---
>>
>> parent = Page.find_by_url('/services/news')
>> child = parent.children.build(:title => "Floods",
>> :breadcrumb => "Floods", :slug => "floods")
>> child.parts.build(:content => "This is a page for flood news",
>> :name => "body")
>> child.save!
>>
>> # ------ end of script to add a new page ---
>>
>> How may I update the contents using script/runner? I have tried
>> the following, but it does not work. Any help to solve this
>> would be much appreciated.
>>
>> # ---- test script that does not work
>>
>> floods = Page.find_by_url('/services/news/floods')
>> floods.parts.build(:content => "This is now for droughts")
>> floods.update
>>
>> thanks in advance,
>>
>> saji
>>
>> _______________________________________________
>> Radiant mailing list
>> Post: [email protected]
>> Search: http://radiantcms.org/mailing-list/search/
>> Site: http://lists.radiantcms.org/mailman/listinfo/radiant
>>
>>
>>
>
> _______________________________________________
> Radiant mailing list
> Post: [email protected]
> Search: http://radiantcms.org/mailing-list/search/
> Site: http://lists.radiantcms.org/mailman/listinfo/radiant
>
>
>
_______________________________________________
Radiant mailing list
Post: [email protected]
Search: http://radiantcms.org/mailing-list/search/
Site: http://lists.radiantcms.org/mailman/listinfo/radiant