Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Saving all pages at once?


Reply

5 Posts   537 Views

Avatar
wilsonStaff

4 February 2012 at 3:47pm Community Member, 142 Posts

Hi guys, i have over 400s pages of the same type. Some created BEFORE i added a script to the Page class, and some created AFTER i added the script.

- The pages created AFTER correctly returns the data while the pages created BEFORE arent.

- Ive noticed while searching for the problem that if i load in the CMS and nothing more that SAVE&PUBLISH the old pages, they update themselves and correctly shows correct the data.

- so id have to manually OPEN and SAVE&PUBLISH over 400s pages.

QUESTION: is there a way to "shock" the DB and save/update/publish all pages at once?

Thanks!

Avatar
swaiba

5 February 2012 at 6:09am (Last edited: 5 February 2012 6:10am), Forum Moderator, 1796 Posts

How about (this untested) code?

$pages = DataObject::get('Page');
if ($pages) foreach ($pages as $page) {
   $page->writeToStage('Stage');
   $page->publish("Stage", "Live");
}

Avatar
wilsonStaff

5 February 2012 at 7:04am Community Member, 142 Posts

Hi, that would make sense if:

- its working (where to put that code bit?)

- it was something i wanted to happen in a repetitive manner

WHICH IS NOT.

I mean, all i what to do is "shock" the entire system ONCE (and saves old pages ONCE) as new pages are rendering correctly.

- - -

Sure i could use a function ONCE, do the job and delete it after. Again, where to wrtei your code?

Page.php?
MemberPage.php? (the pages i want to get saved again)

But i was thinking more on the /dev/build side. There must be a routine that does that.

Keep the solutions coming!

Avatar
simon_w

5 February 2012 at 9:15am Forum Moderator, 474 Posts

http://yoursite.com/admin/publishall

Avatar
wilsonStaff

5 February 2012 at 4:03pm (Last edited: 5 February 2012 4:08pm), Community Member, 142 Posts

http://yoursite.com/admin/publishall

- - -

Yup, it worked.

Thanks!