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.

Themes /

Discuss SilverStripe Themes.

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

How dynamicaly change site theme?


Go to End


4 Posts   1637 Views

Avatar
alex_sm

Community Member, 19 Posts

15 July 2017 at 12:08am

I have made for my site additional theme for cecutients. Can I dynamicaly change site theme pushing some button on the main page?

Avatar
RanjitS

Community Member, 1 Post

21 July 2017 at 10:32pm

That's really a great solution Alex_SM... your answer solves my problem. Thank you very much for sharing a helpful link.

Avatar
alex_sm

Community Member, 19 Posts

21 July 2017 at 10:36pm

Edited: 21/07/2017 10:47pm

You are welcome! One notice. In the case when you have several themes add some code :

class Page_Controller extends ContentController 
{
    private static $allowed_actions = ['changeTheme'];

    public function init(){
        parent::init();

        if ($theme = Session::get('theme')) {
            Config::inst()->update('SSViewer', 'theme', $theme);
        } else {Config::inst()->update('SSViewer', 'theme', 'your_default_theme');}
    }
 

.............