Under the Parameters section of the drupal_add_css() function, the documentation says this:
$path (optional) The path to the CSS file relative to the base_path(), e.g., /modules/devel/devel.css.
I believe this is incorrect; the CSS file should not include a preceding slash. The example should instead be
$path (optional) The path to the CSS file relative to the base_path(), e.g., modules/devel/devel.css.
In the drupal_get_css() function, one can see that base_path() is actually prepended onto the filename. I'm looking specifically at one of the lines that looks like this:
$no_module_preprocess .= '<link type="text/css" rel="stylesheet" media="'. $media .'" href="'. base_path() . $file . $query_string .'" />'."\n";
I spent a few hours today trying to find out why my calls to drupal_add_css() weren't working, only to track it down to this. Hopefully this can be fixed soon, if this is indeed a bug.
Thanks :)
-wyrmmage
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | drupal_add_css-618280-D6.patch | 515 bytes | daniels220 |
Comments
Comment #1
valkire commentedComment #2
jhodgdonUpdating tags and version.
Comment #3
jhodgdonNote that this is not an issue in Drupal 7.x.
Comment #4
heine commentedCopied from #785314: drupal_add_css path documentation is incorrect, because it is not just the example that is wrong:
$path (optional) The path to the CSS file relative to the drupal root, e.g., modules/devel/devel.css.
Comment #5
jhodgdonAnother good project for a novice doc contributor
Comment #6
daniels220 commentedPatch attached. I didn't modify any of the language except fixing the /. That's important—everything else I'll leave to others to discuss.
Comment #7
jhodgdonI don't understand Heine's comment in #4. base_path() is the same as the Drupal root, I think?
I think this patch is fine.
Comment #8
gábor hojtsyThanks, committed.