Broken Link to style.css

Steve McKenzie - July 6, 2006 - 17:37
Project:Onlinestatus Indicator
Version:HEAD
Component:Code
Category:bug report
Priority:normal
Assigned:Steve McKenzie
Status:closed
Description

These occurs when using clean urls and under paths not under root.. so example,

user/uid .. it would look for the styles in
user/modules/onlinestatus/style.css instead of
/modules/onlinestatus/style.css

so this patch brings in global $base_url and fixes that. We can't simply just add a / in it because some people put their installs in a folder to it self.

AttachmentSize
broken_style_css_link.patch984 bytes

#1

xeniac - July 7, 2006 - 06:41

I reconfigured my local apache2 installation, with mod_rewrite to test it out with cleanurls enabled.
drupal_get_path called on http://localhost/j-fan.at/user/8 created the right path for me (/j-fan.at/modules/onlinestatus/style.css).
Seems that i can't recreate this false behaviour so easy...
On the other side, i really don't like this line:

<?php
drupal_set_html_head
('<style type="text/css">@import url('.drupal_get_path('module','onlinestatus').'/style.css);</style>');
?>

I think i should use theme_add_style() instead, this also uses $base_url and my function does not need to import a global var.
Could you try out if this runs smoothly on your configuration:
<?php
/**
* Displays the Onlinestatus of all Messenger on the Userprofile Page
*/
function theme_onlinestatus_profile($user) {
 
$items = array();
 
theme_add_style(drupal_get_path('module','onlinestatus').'/style.css');
  foreach (
onlinestatus_get_messengers(true) as $messenger => $title) {
?>

#2

Steve McKenzie - July 7, 2006 - 07:06

my bad.. i forgot the right way to do this..

this is right now..

your not suppose to use theme_add_style. you never wana call a theme function directly.

we want..

<?php
drupal_set_html_head
(theme('stylesheet_import', base_path() .drupal_get_path('module','onlinestatus').'/style.css'));
?>

AttachmentSize
css_fix.patch 863 bytes

#3

xeniac - July 7, 2006 - 08:47

I found the Answer for all questions on http://drupal.org/node/60096:

Modules, on the other hand, should not be using theme_add_style because situations can develop in which themers cannot override module-specific CSS. (module CSS should be referenced BEFORE all theme CSS) For this reason, modules should use drupal_set_html_head instead.

Having theme('add_style') and theme('import_style') is to confusing.

I will add your Patch for the next release, but i have to fix the MSN Bug bevor i can commit the changes to CVS.

#4

Steve McKenzie - July 7, 2006 - 18:56

cool.

this is something drupal needs documented on a page in the handbook!

thanks xeniac

#5

xeniac - April 19, 2007 - 10:01
Status:active» fixed

Drupal 4.7 uses
drupal_set_html_head(theme('stylesheet_import', base_path() .drupal_get_path('module','onlinestatus').'/style.css'));

The New DRUPAL-5 Branch makes use of the new drupal_add_css() instead.

This Bug is fixed.

#6

Anonymous - May 3, 2007 - 10:16
Status:fixed» closed
 
 

Drupal is a registered trademark of Dries Buytaert.