Some projects need a custom Startpage extended from SiteTree, other dont.
Until now ive hacked into cmc/code/model/SiteTree.php and changed line ~ 1464 to $homepage = new SartPage();
Thats not very comfortable. To make things more flexible i am trying to set :
_config.php:
// SiteTree create StartPage? // true = normal setup // false = creates custom StartPage
SiteTree::set_create_default_pages(false);
and on Startpage.php:
class StartPage extends SiteTree {
public function requireDefaultRecords() {
parent::requireDefaultRecords();
if(!$this->config()->create_default_pages) {
if(!StartPage::get()->exists()) {
$page = new StartPage();
$page->Title = 'StartPage';
$page->URLSegment = Config::inst()->get('RootURLController', 'default_homepage_link');
$page->Sort = 1;
$page->Content = 'the StartPage page test';
$page->Status = "Published";
$page->write();
$page->publish('Stage', 'Live');
DB::alteration_message('StartPage created', 'created');
}
}
}
public static $allowed_children = 'none';
function canCreate($Member = null){
return false;
}
function canDelete($Member = null){
return false;
}
function canDeleteFromLive($Member = null){
return false;
}
public static $hide_ancestor = 'StartPage';
Now the StartPage is created but ErrorPages are missing.
(Forget about -> About Us and Contact Us ) as ?nobody? needs them.
In cmc/code/model/ErrorPage its the same if clause:
if ($this->class == 'ErrorPage' && SiteTree::config()->create_default_pages) {
How can i manage to create the custom StartPage and the default ErrorPages ?
Thanks.timo.