Jump to:

1374 Posts in 487 Topics by 520 members

Themes

SilverStripe Forums » Themes » Set default theme (SSViewer::set_theme) programatically in _ss_environment.php instead of _config.php

Discuss SilverStripe Themes.

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

Page: 1
Go to End
Author Topic: 1263 Views
  • vwd
    Avatar
    Community Member
    158 Posts

    Set default theme (SSViewer::set_theme) programatically in _ss_environment.php instead of _config.php Link to this post

    Hi,

    We've structured our SS projects so that all project specific configuration goes into _ss_environment.php, leaving _config.php to be as generic as possible, so that we can include it in our SS project boilerplate.

    One thing that unfortunately is project specific is the call to SSViewer::set_theme(). From our reading of the forums, we get the impression that it is recommended to set a default theme programmatically, so we'd like to do that somewhere.

    The question is where can we do this (preferably somewhere project-specific like _ss_environment.php) and outside of _config.php.

    Is what we're doing here, OK... we define a constant in ss_environment.php that is then used in the _config.php's SSViewer::set_theme call. Eg...

    _ss_environment.php

    ...
    define('SS_PROJ_DEFAULT_THEME', 'MyDefaultTheme');
    ...

    _config.php

    ...
    SSViewer::set_theme(SS_PROJ_DEFAULT_THEME);
    ...

    Seems to work well. Sounds OK?

    Thanks for your input.

    VWD.

  • Willr
    Avatar
    Forum Moderator
    5490 Posts

    Re: Set default theme (SSViewer::set_theme) programatically in _ss_environment.php instead of _config.php Link to this post

    This is perfectly fine. The reason you cannot use SSViewer::set_theme() in your environment is that the class isn't loaded but a constant is perfectly valid to be used.

  • vwd
    Avatar
    Community Member
    158 Posts

    Re: Set default theme (SSViewer::set_theme) programatically in _ss_environment.php instead of _config.php Link to this post

    Thanks Will - appreciate your response very much.

    VWD.

    1263 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.