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.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

General Questions /

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

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

Saving all pages at once?


Go to End


5 Posts   870 Views

Avatar
wilsonStaff

Community Member, 143 Posts

4 February 2012 at 3:47pm

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

Forum Moderator, 1899 Posts

5 February 2012 at 6:09am

Edited: 05/02/2012 6:10am

How about (this untested) code?

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

Avatar
wilsonStaff

Community Member, 143 Posts

5 February 2012 at 7:04am

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
(deleted)

Community Member, 473 Posts

5 February 2012 at 9:15am

Avatar
wilsonStaff

Community Member, 143 Posts

5 February 2012 at 4:03pm

Edited: 05/02/2012 4:08pm

http://yoursite.com/admin/publishall

- - -

Yup, it worked.

Thanks!