I can not for the life of me get a custom admin working, I've followed the docs here:
http://doc.silverstripe.org/framework/en/reference/sitetree
and keep getting the error:
Page type "X Page" is not allowed on the root level
I want my articles administered through the left menu and not appearing as sub pages in the site tree.
Article Holder .php
<?php
class ArticleHolder extends Page {
private static $allowed_children = array('ArticlePage');
private static $default_child = 'ArticlePage';
}
<?php
class ArticlePage extends Page {
private static $db = array(
'Date' => 'Date',
'Author' => 'Text'
);
private static $allowed_children = 'none';
private static $can_be_root = false;
public function getCMSFields() {
$fields = parent::getCMSFields();
$dateField = new DateField('Date', 'Published Date');
$dateField->setConfig('showcalendar', true);
$dateField->setConfig('dateformat', 'dd/MM/YYYY');
$fields->addFieldToTab('Root.Main', $dateField, 'Content');
$fields->addFieldToTab('Root.Main', new TextField('Author', 'Author Name'), 'Content');
return $fields;
}
public function populateDefaults() {
$this->Date = date('Y-m-d');
$this->Author = 'Patrick';
parent::populateDefaults();
}
}
class ArticlePage_Controller extends Page_Controller {
}
class ArticleAdmin extends ModelAdmin {
private static $managed_models = array('ArticlePage'); // Can manage multiple models
private static $url_segment = 'articles'; // Linked as /admin/products/
private static $menu_title = 'Articles';
private static $icon = "cms/images/treeicons/news-file.gif";
}
class Article extends DataObject {
// ...
private static $searchable_fields = array(
'Page Name',
'Content'
// leaves out the 'Price' field, removing it from the search
);
}
Help much appreciated, once cracked I can fly through my other parts.