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.

Themes

Discuss SilverStripe Themes.

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

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


Reply

3 Posts   1360 Views

Avatar
vwd

7 October 2011 at 4:16pm Community Member, 159 Posts

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

7 October 2011 at 9:51pm Forum Moderator, 5511 Posts

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

7 October 2011 at 10:35pm Community Member, 159 Posts

Thanks Will - appreciate your response very much.

VWD.