Hey there,
I'm new to Silverstripe.
I want to show a Custom-Header on every Page, so I created a DataObject called Header.
class Header extends DataObject{
const BUTTONS = "Enum('NONE, DONATE, BECOME_MEMBER', 'NONE')";
static $db = array(
'Title' => 'Varchar(255)',
'GeneralDescription' => 'Text',
'BigButton' => self::BUTTONS,
'SmallButton' => self::BUTTONS
);
static $has_one = array(
'BackgroundImage' => 'Image',
);
static $has_many = array(
'Pages' => 'Page'
);
}
Every Page now should have a connection to a header. It should be possible to choose either a existing Header-Entry or create a new one (simple drowdown isn't enough). This is how Page.php looks like:
class Page extends SiteTree {
public static $db = array(
);
public static $has_one = array(
'Header' => 'Header'
);
public function getCMSFields(){
$fields = parent::getCMSFields();
//what to add here?
return $fields;
}
}
Can I use a GridField here? This would be the functionality I want to have. The problem is, that GridFields only work for Lists and not for single Models?
Thanks!