[development] $custom_theme when does it take effect... when does it not

Dave Cohen drupal at dave-cohen.com
Thu Aug 14 23:06:39 UTC 2008

As Earl points out, $custom_theme only has effect before init_theme() is run.  
Afterward, it's too late.  So when you set $custom_theme you had better be 
sure no code has called theme(...) yet.  You can check with:

global $theme;
if (isset($theme)) {
  // too late to set $custom_theme.

And look out for modules that set $custom_theme without checking first whether 
some other module has set it.  (I won't name names, but initials are "og")  
So if you want to set the custom theme and make sure noone overrides it, call 
theme(...) right after you set $custom_theme.


On Thursday 14 August 2008, Earl Miles wrote:
> $custom_theme takes effect as soon as init_theme() is run. 
> [snip] ... as long as some module isn't calling theme(...) ...

More information about the development mailing list