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

Overloading requireDefaultRecords for Home


Reply

2 Posts   448 Views

Avatar
zenmonkey

20 December 2012 at 5:53am Community Member, 528 Posts

Is there anyway to change the PageType for Home in the requireDefaultRecords() to differnt page type other than Page without editing the core file?

Avatar
Willr

20 December 2012 at 8:10pm Forum Moderator, 5511 Posts

Sure, requireDefaultRecords is run once per class so on your Page.php

function requireDefaultRecords() {
parent::requireDefaultRecords();

$home = DataObject::get_one("Page", "URLSegment = 'home'");
$home->ClassName = "NewSomethingClass";
$home->write();
$home->publish('Stage', 'Live');
}