Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I'm using the latest Drupal 7.0 (January 5, 2011). The new CSS rule is not added, unnecessarily path on the resulting page is not correct.
Example:
Addeed: http://dl.dropbox.com/u/15840231/1.jpg
Incorrect path:
<style type="text/css" media="all">@import url("http://localhost/drupal7/sites%5Cdefault%5Cfiles%5Ccss_injector%5Ccss_injector_2.css?lfsxhg");</style>
<!--//--><![CDATA[//><!--
jQuery.extend(Drupal.settings, {"basePath":"\/drupal7\/","ajaxPageState":{"theme":"corolla","theme_token":"PHsZ26M8W_RQ2S6LiynCnb5OG3Ty4tr-i_VxsGbT_wY","js":{"misc\/jquery.js":1,"misc\/jquery.once.js":1,"misc\/drupal.js":1,"misc\/ui\/jquery.ui.core.min.js":1,"misc\/jquery.ba-bbq.js":1,"modules\/overlay\/overlay-parent.js":1,"modules\/contextual\/contextual.js":1,"misc\/jquery.cookie.js":1,"public:\/\/languages\/ru_lhv-lT85NFzK5S8rzoq9s5uttLBrc1JcECVUpbJO7Yg.js":1,"modules\/dhtml_menu\/dhtml_menu.js":1,"modules\/toolbar\/toolbar.js":1},"css":{"modules\/system\/system.base.css":1,"modules\/system\/system.menus.css":1,"modules\/system\/system.messages.css":1,"modules\/system\/system.theme.css":1,"misc\/ui\/jquery.ui.core.css":1,"misc\/ui\/jquery.ui.theme.css":1,"modules\/overlay\/overlay-parent.css":1,"modules\/contextual\/contextual.css":1,"modules\/comment\/comment.css":1,"modules\/field\/theme\/field.css":1,"modules\/node\/node.css":1,"modules\/poll\/poll.css":1,"modules\/search\/search.css":1,"modules\/user\/user.css":1,"modules\/dhtml_menu\/dhtml_menu.css":1,"themes\/corolla\/reset.css":1,"0":1,"modules\/toolbar\/toolbar.css":1,"modules\/shortcut\/shortcut.css":1,"themes\/corolla\/base.css":1,"themes\/corolla\/style.css":1,"themes\/corolla\/colors.css":1,"themes\/corolla\/print.css":1,"themes\/corolla\/ie8.css":1,"themes\/corolla\/ie7.css":1,"sites\\default\\files\\css_injector\\css_injector_2.css":1}},"dhtmlMenu":{"nav":"open","animation":{"effects":{"height":"height","opacity":"opacity"},"speed":500},"effects":{"siblings":"close-same-tree","children":"none","remember":0},"filter":{"type":"blacklist","list":[]}},"overlay":{"paths":{"admin":"node\/*\/edit\nnode\/*\/delete\nnode\/*\/revisions\nnode\/*\/revisions\/*\/revert\nnode\/*\/revisions\/*\/delete\nnode\/add\nnode\/add\/*\noverlay\/dismiss-message\nuser\/*\/shortcuts\nadmin\nadmin\/*\nbatch\ntaxonomy\/term\/*\/edit\nuser\/*\/cancel\nuser\/*\/edit\nuser\/*\/edit\/*","non_admin":"admin\/structure\/block\/demo\/*\nadmin\/reports\/status\/php"},"ajaxCallback":"overlay-ajax"},"tableHeaderOffset":"Drupal.toolbar.height"});
//--><!]]>
My user page: http://dl.dropbox.com/u/15840231/user.htm
Comment | File | Size | Author |
---|---|---|---|
#12 | css_injector.fix_path_fiddling_1044670_12.patch | 3.91 KB | rfay |
Comments
Comment #1
rfayThe most recent dev release of CSS Injector is dated December 25.
I can't demonstrate any problems. Just created a rule
.content { color: red; }
and it works fine.
Perhaps you can go through step by step, explaining what you were trying to do and provide the rule that failed for you.
Comment #2
fir1st CreditAttribution: fir1st commentedAnd why may be incorrect path?
Comment #3
juggler CreditAttribution: juggler commentedI have the same issue.
The url of the css file seems to be wrong:
http://localhost/drupal7/sites%5Cdefault%5Cfiles%5Ccss_injector%5Ccss_in...
It uses %5c (code for \) instead of /.
Im running this test-site on windows 7, maybe that's why its using backslash instead of slash.
If I go to: admin/config/development/css_injector
the filepath of my defined rule is:
sites\default\files\css_injector\css_injector_1.css
it's with backslash instead of slash. Maybe this info helps.
How can I fix it?
Thanks
Comment #4
juggler CreditAttribution: juggler commentedIt seems that the function call
drupal_realpath(_css_injector_rule_uri($crid));
returns a path with backslashes in windows.
If I add this line of code to the function "function _css_injector_rule_path($crid)":
$local_path = str_replace('\\', '/', $local_path);
everything works fine
Comment #5
rfaydrupal_realpath shouldn't be used for generating the URL, so that's the bug here. This should be using file_create_url($uri) instead.
Comment #6
drubeedoo CreditAttribution: drubeedoo commentedStill an issue... using XAMPP in Windows with Drupal 7.4 and latest version of css_injector-7.x-1.5.
CSS file is not loading due to CSS Injector output containing "%5C" instead of "/" in path. See path to file as generated by module:
Thanks for looking into this...
Comment #7
rfay#5 explains the fix if somebody wants to roll a patch.
Comment #8
rfay#5 explains the fix if somebody wants to roll a patch.
Comment #9
gappleTried to get started on this, but file_create_url($uri) returns an absolute path.
The following works if you can assume that the public:// stream wrapper uses the same domain and base path as the drupal root.
There has to be a better way to get a relative path from the stream wrapper if possible though, and some logic may be required to add the CSS to the page as an external path if a relative path is not possible (e.g. it's stored on a CDN)
Comment #10
bwill CreditAttribution: bwill commentedThis is an issue for me as well. My path is /sites%5Cdefault%5Cfiles%5Ccss_injector%5Ccss_injector_1.css?logl8a");
which does not work. My CSS code is:
Comment #11
gappleHere is another option, based on a patch to Insert module (#622964-51: Provide UI option for using relative urls for the inserted images).
It looks to be smarter in checking if the absolute path to the file matches the site's url and base path.
Comment #12
rfayThis patch simplifies the code and I think is the correct approach.
Please review it and test on all platforms. It affects the admin display, deletion of rules, and adding rules in addition to loading the CSS, so there are a few things that can break.
That said, it works for me on both linux and Windows (under xampp)
Comment #13
gappleonly one $id has been changed to $crid here.
Other than that, things look good and work properly on my Win environment. Digging through Drupal's CSS code it looks like since it uses file_create_url itself to ouput links when aggregation is disabled, it can handle paths to shipped files and stream wrappers even though the documentation for drupal_add_css only mentions shipped files.
Comment #14
bwill CreditAttribution: bwill commentedThe patch worked for me - running on Windows 7 in IE8. Thanks a bunch! This is a most excellent module! I even used it to display a background image behind my contact form!
Comment #15
rfayThanks, @gapple, for the careful review.
Since I seem to be the only committer hanging around here I've committed this with your change :=)
Committed: aea7119
We need to get out a new release, so if you all could test the dev and report back, that would be great.
Thanks to all for the work and the patience on this one. It actually resolves a number of other reported issues.