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   462 Views

Avatar
zenmonkey

Community Member, 528 Posts

20 December 2012 at 5:53am

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

Forum Moderator, 5513 Posts

20 December 2012 at 8:10pm

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