Force specific theme

Permalink
Hi

Can anyone shed some light on how to force a particular theme?

I want to be able to do;

if($x)
    define("THEME", "my_theme");


I need to be able to force a specific theme under certain conditions, overriding the normal theme?

Thanks.

yolk
 
jordanlev replied on at Permalink Best Answer Reply
jordanlev
If the situations are just that you want certain pages to use certain themes, use the config/site_theme_paths.php file. Otherwise, you can use this code:
$theme = PageTheme::getByHandle('your_theme_handle');
$view = View::getInstance();
$view->setTheme($theme);


But note that this must occur before the theme starts to render... so it can't be in your theme templates or block views. I think you could put it in an on_page_view event somewhere.
yolk replied on at Permalink Reply
yolk
Thanks Jordan.

This is what I ended up doing.