Jump to:

23367 Posts in 18143 Topics by 2863 members

General Questions

SilverStripe Forums » General Questions » Saving all pages at once?

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

Page: 1
Go to End
Author Topic: 513 Views
  • wilsonStaff
    Avatar
    Community Member
    142 Posts

    Saving all pages at once? Link to this post

    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!

  • swaiba
    Avatar
    Forum Moderator
    1784 Posts

    Re: Saving all pages at once? Link to this post

    How about (this untested) code?

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

  • wilsonStaff
    Avatar
    Community Member
    142 Posts

    Re: Saving all pages at once? Link to this post

    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!

  • simon_w
    Avatar
    Forum Moderator
    471 Posts
  • wilsonStaff
    Avatar
    Community Member
    142 Posts

    Re: Saving all pages at once? Link to this post

    http://yoursite.com/admin/publishall

    - - -

    Yup, it worked.

    Thanks!

    513 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.