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've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Customising the CMS /

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

Add CMS user theme switcher


Go to End


1756 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