[development] Switching themes in modules
Moshe Weitzman
weitzman at tejasa.com
Wed Jun 21 17:34:02 UTC 2006
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'));
> ?>
>
> see http://drupal.org/node/52508#comment-79259
well, i have two minor objections to this
- theme_stylesheet_import is not intended as a themeable function. you
should call it directly, not indirectly through theme(). the problem with
calling through theme() is that you initialize the theme layer which should
be done at the latest possible stage. doing it in hook_menu() hurts theme
switching based on organic group., sections, path, taxonomy, etc.
- it is wordy compared to just theme_add_style(). presumably that could be
fixed with another theme function or reworking existing ones
More information about the development
mailing list