Skip to content

Instantly share code, notes, and snippets.

@dljoseph
Created November 22, 2014 07:44
Show Gist options
  • Save dljoseph/263f78375652cb079c5c to your computer and use it in GitHub Desktop.
Save dljoseph/263f78375652cb079c5c to your computer and use it in GitHub Desktop.
SilverStripe Auto-create page type on dev/build
/**
* Create default Info Page setup
*/
function requireDefaultRecords() {
parent::requireDefaultRecords();
// Skip creation of default records
if(!self::config()->create_default_pages) return;
$infoPage = InfoPage::get()->first();
if(!$infoPage) {
$infoPage = new InfoPage();
$infoPage->Title = "Our Story";
$infoPage->URLSegment = 'about';
$infoPage->Content = "";
$infoPage->Status = "Published";
$infoPage->ParentID = 0;
$infoPage->write();
$infoPage->publish("Stage", "Live");
DB::alteration_message("Info Page created","created");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment