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:

Themes /

Discuss SilverStripe Themes.

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

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


Go to End


3 Posts   4098 Views

Avatar
vwd

Community Member, 166 Posts

7 October 2011 at 4:16pm

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.

Avatar
Willr

Forum Moderator, 5523 Posts

7 October 2011 at 9:51pm

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.

Avatar
vwd

Community Member, 166 Posts

7 October 2011 at 10:35pm

Thanks Will - appreciate your response very much.

VWD.