[development] Switching themes in modules

Gordon Heydon gordon at heydon.com.au
Wed Jun 21 23:22:19 UTC 2006


Hi,

Nedjo Rogers wrote:
>> @all - the right way to add a custom stylesheet from a module is 
>> theme_add_style().
> 
> TDobes offers convincing arguments that we should instead use
> 
> <?php
> // Modules should do:
> drupal_set_html_head(theme('stylesheet_import', base_path() . 
> drupal_get_path('module', 'mymodule') .'/mymodule.css'));
> ?>

If you are using this from hook_menu() do not use the theme() as it will 
initialise the theme, and you will not be able to change it.

Gordon.

> see http://drupal.org/node/52508#comment-79259
> 
> !DSPAM:1000,44997ed5176845696618876!
> 


More information about the development mailing list