[documentation] [Documentation bug] theme('stylesheet_import'... in modules stops block/theme preview

Heine drupal-docs at drupal.org
Tue Apr 25 11:33:46 UTC 2006


Issue status update for 
http://drupal.org/node/60096
Post a follow up: 
http://drupal.org/project/comments/add/60096

 Project:      Documentation
 Version:      <none>
 Component:    Developer Guide
 Category:     bug reports
 Priority:     critical
 Assigned to:  Anonymous
 Reported by:  kiz_0987
 Updated by:   Heine
 Status:       active

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.




Heine



Previous comments:
------------------------------------------------------------------------

Mon, 24 Apr 2006 11:35:39 +0000 : kiz_0987

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




------------------------------------------------------------------------

Mon, 24 Apr 2006 18:01:48 +0000 : Zen

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


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


Thanks :)
-K




------------------------------------------------------------------------

Mon, 24 Apr 2006 18:16:02 +0000 : profix898

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




------------------------------------------------------------------------

Mon, 24 Apr 2006 18:27:13 +0000 : kiz_0987

As per profix898, moving back to bug report.




------------------------------------------------------------------------

Mon, 24 Apr 2006 18:31:37 +0000 : Zen

oops! Thanks for the cover profix :P


Setting it back to bug report.


-K




------------------------------------------------------------------------

Mon, 24 Apr 2006 19:19:00 +0000 : Dries

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.




------------------------------------------------------------------------

Tue, 25 Apr 2006 10:33:54 +0000 : kiz_0987

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






More information about the documentation mailing list