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'));

Doing this though stops the theme preview from occuring when editing the blocks (switching the theme at the top of the blocks page should provide a preview).

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:-)

Comments

Zen’s picture

Category: bug » support
Priority: Critical » Normal

Please read http://drupal.org/node/52508

Changing to a support request. If you still face any issues, please recategorise this issue.

Thanks :)
-K

profix898’s picture

Priority: Normal » Critical

@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 ...

kiz_0987’s picture

Category: support » bug

As per profix898, moving back to bug report.

Zen’s picture

oops! Thanks for the cover profix :P

Setting it back to bug report.

-K

dries’s picture

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.

chx’s picture

Project: Drupal core » Documentation
Component: block.module » Developer Guide

 

kiz_0987’s picture

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', ..."?

heine’s picture

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.

thinkinkless’s picture

Version: x.y.z »
Status: Active » Closed (fixed)

closing (4.7)

avpaderno’s picture

Project: Documentation » Drupal core
Version: » 4.7.x-dev
Component: Developer Guide » ajax system
Issue summary: View changes