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.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Customising the CMS /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Add CMS user theme switcher


Go to End


1372 Views

Avatar
spencer

Community Member, 8 Posts

30 December 2009 at 7:09am

Hello,

I am trying to add the theme switcher in this post. http://www.silverstripe.org/customising-the-cms/show/252519 However, I am not sure where root.content.main is located I thought it would be in leftandmain.php but could not find it. any help would be greatly appreciated.

<?php

class Page extends SiteTree {
static $db = array(
'ThemeX' => "Enum('higherground,blackcandy','higherground')"
);
static $has_one = array(
);

function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldToTab('Root.Content.Main', new DropdownField(
'ThemeX',
'Select A Theme:',
singleton('Page')->dbObject('ThemeX')->enumValues()
));

return $fields;}
}

class Page_Controller extends ContentController {
function init() {

SSViewer::set_theme($this->ThemeX);

parent::init();

Requirements::themedCSS("layout");
Requirements::themedCSS("typography");
Requirements::themedCSS("form");
}
}

?>

Thanks,

Spencer