Jump to:

23550 Posts in 19336 Topics by 2890 members

General Questions

SilverStripe Forums » General Questions » Populating Default Records in SS3 Page Types

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: 544 Views
  • novaweb
    Community Member
    115 Posts

    Populating Default Records in SS3 Page Types Link to this post


    In SS2 we used public static $default_records with a nested array to populate the default records we wanted upon page creation.

    In SS3, looking through SiteTree, I assumed this was now just static $defaults, however this only populates the URLSegment... not the Title etc.


    Anyone know?


  • Mojo5000
    Community Member
    5 Posts

    Re: Populating Default Records in SS3 Page Types Link to this post

    I know the post is kind of old, but here is an example, not sure if it answers your Q.

    In your Page class:

    function requireDefaultRecords() {
    if(class_exists('MyPage') && !DataObject::get_one('MyPage')) {
    $page = new WeaponsPage();
    $page->Title = 'My Page';
    $page->URLSegment = 'mypage1';
    $page->Status = 'Published';
    $page->Sort = 2;
    $page->publish('Stage', 'Live');
    DB::alteration_message('MyPage created.', 'created');

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.