setThemeByPath Dynamic?

Permalink 1 user found helpful
Hiii..

i try to figure out how to make setThemeByPath dynamic.

for now i just harcoded it in site_theme_paths.php
$default = 'yogurt';
$v = View::getInstance();
$v->setThemeByPath('/login', $default);
$v->setThemeByPath('/page_forbidden', $default);
...


the problem is when we change default theme via dashboard, this not change

how we can know the default current theme?

where is the c5 query loaded the default theme? i cannot find it


thanks.

fastcrash
 
ScottC replied on at Permalink Best Answer Reply
ScottC
$p = Page::getByID(HOME_CID);
$theme = $p->getCollectionThemeObject();
$default = $theme->getThemeHandle();
$v = View::getInstance();
$v->setThemeByPath('/login', $default);
$v->setThemeByPath('/page_forbidden', $default);
fastcrash replied on at Permalink Reply
fastcrash
Scottc you are really a rockstar, the legend, the myth, etc :)
thanks a lot dude

this the first time i see that code :)
ScottC replied on at Permalink Reply
ScottC
The myth? Hey i'm around ;)

-scott
mkly replied on at Permalink Reply
mkly
This is really helpful. Mind if I wrap this up in a howto?
ScottC replied on at Permalink Reply
ScottC
I don't see why not, this is pretty straightforward.

Just give me credit or something in it somewhere, referencing this post?
CIRESatCU replied on at Permalink Reply
Hi - I'm trying to use this method to set my themes for different sections within my site. I'm not having such great luck; it seems to work fine for single pages, but doesn't cascade down through the structure of my site.

For example, I have:
$p = Page::getByID(HOME_CID);
$theme = $p->getCollectionThemeObject();
$default = $theme->getThemeHandle();
$v = View::getInstance();
$v->setThemeByPath('/esoc', "ESOC");
$v->setThemeByPath('/limnology', "CIRES");
$v->setThemeByPath('/eo', "ESOC");

I want the theme ESOC to be allowed to the /esoc/ directory and everything within it. However, when I add the trailing slash behind 'esoc' it doesn't work. If I remove the trailing slash, it works only for the page /esoc/ but no subsequent pages beneath it.

Do you know of a way to make this cascade down for everything starting at /esoc/ and all its subpages?

Thanks for any help you can provide!
-Kiki