I'm by no means any sort of expert when it come to coding or php but I am trying to implement a drop down box in the cms on Root.content.main that will allow the user to set the theme for the page.
I could but completely off but this is the code I have come up with so far... as now I getting a parse error on line "SSViewer::set_theme('$Theme');"
---------------------------
<?php
class Page extends SiteTree {
static $db = array(
'Theme' => "Enum('higherground,blackcandy','higherground')"
);
static $has_one = array(
);
function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldToTab('Root.Content.Main', new DropdownField(
'Theme',
'Select A Theme:',
singleton('Page')->dbObject('Theme')->enumValues()
));
return $fields;}
}
class Page_Controller extends ContentController {
function init() {
switch($this->URLSegment) {
SSViewer::set_theme('$Theme');
break;
}
parent::init();
Requirements::themedCSS("layout");
Requirements::themedCSS("typography");
Requirements::themedCSS("form");
}
}
?>
P.S. LOVE SilveStripe!!!