theme('stylesheet_import'... in modules stops block/theme preview
kiz_0987 - April 24, 2006 - 11:35
| Project: | Documentation |
| Component: | Developer Guide |
| Category: | bug report |
| Priority: | critical |
| Assigned: | Unassigned |
| Status: | closed |
Jump to:
Description
In http://drupal.org/node/52508#comment-79259 (and http://drupal.org/node/22218 ) it states that the correct way for modules to include css is to use
drupal_set_html_head(theme('stylesheet_import', base_path() . drupal_get_path('module', 'mymodule') .'/mymodule.css'));Using theme_add_style('misc/local/my_custom_style.css'); correctly previews the theme, but according to the post above is definitely NOT supposed to be used.
I've put this as critical partly for the bug, but also because I notice some modules (eg event) are using the theme_add_style version. Some extra clarity is needed for module authors I think (like me:-)

#1
Please read http://drupal.org/node/52508
Changing to a support request. If you still face any issues, please recategorise this issue.
Thanks :)
-K
#2
@Zen: You should read issues more carefully ;) The link you posted is the same listed in the issue description! It tells module developers to use
drupal_set_html_head(theme('stylesheet_import', ...). But doing so makes it impossible to configure blocks per theme ...#3
As per profix898, moving back to bug report.
#4
oops! Thanks for the cover profix :P
Setting it back to bug report.
-K
#5
The difference between both functions is not clear based on looking at their name. Hence, the confusion. Using theme_add_style('misc/local/my_custom_style.css'); appears to make sense.
It would be a good idea to clean up the naming scheme (or to eliminate the need for both functions). Probably some post 4.7.0 task.
#6
#7
I can see the need for improved documentation, but there is still a bug here.
drupal_set_html_head(theme('stylesheet_import', base_path() . drupal_get_path('module', 'mymodule') .'/mymodule.css'));stops theme preview from working. Or is the documentation going to say "don't use drupal_set_html_head(theme('stylesheet_import', ..."?#8
The problem of theme('stylesheet_import') in hook_menu or hook_init is the call to theme(), initializing the theme system. Later calls to init_theme silently return & the switch fails.
The theme_add_style('misc/local/my_custom_style.css'); or theme_stylesheet_import do not call the theme function so the switch can still happen.
#9
closing (4.7)