[development] Switching themes in modules

Moshe Weitzman weitzman at tejasa.com
Tue Jun 20 13:08:47 UTC 2006


Gordon Heydon wrote:
> Hi,
> 
> I have done a bit of work in this area for a client, and basically what 
> happens is that you can change the $custom_theme at time time up until 
> the first theme() is called.
> 
> When the first theme() is called it will run the theme_init() which will 
> load the theme. So it will look at $custom_theme and other places and 
> load it.
> 
> The problem that I found a lot of contrib modules during hook_menu() 
> will call theme() to do something that is not theme related or add the 
> css to the page, and the theme will be set.
> 
> The problem is with a lot of contrib modules calling theme() far too early.

right. i wish it were not possible mistakenly initialize the theme. we 
should fix this in the theme api. a good start would be to rename all 
functions that begin with theme_ that *aren't* intended to be themeable 
functions. theme_add_style(), theme_blocks(), ...

@all - the right way to add a custom stylesheet from a module is 
theme_add_style().


More information about the development mailing list