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

#1

Zen - April 24, 2006 - 18:01
Category:bug report» support request
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

#2

profix898 - April 24, 2006 - 18:16
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 ...

#3

kiz_0987 - April 24, 2006 - 18:27
Category:support request» bug report

As per profix898, moving back to bug report.

#4

Zen - April 24, 2006 - 18:31

oops! Thanks for the cover profix :P

Setting it back to bug report.

-K

#5

Dries - April 24, 2006 - 19:19

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

chx@drupal.org - April 25, 2006 - 05:21
Project:Drupal» Documentation
Component:block.module» Developer Guide

#7

kiz_0987 - April 25, 2006 - 10:33

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

Heine - April 25, 2006 - 11:33

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

thinkinkless - March 7, 2008 - 18:28
Version:x.y.z» <none>
Status:active» closed

closing (4.7)

 
 

Drupal is a registered trademark of Dries Buytaert.