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, Ed, biapar, Willr, Ingo, swaiba

Populating Default Records in SS3 Page Types

Go to End

2 Posts   1705 Views


Community Member, 115 Posts

21 February 2013 at 4:01pm


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?



Community Member, 5 Posts

19 November 2013 at 4:43pm

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');