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.
Would there be a way to ensure the css injector css files are loaded last by Drupal? Otherwise, it's hard to use it to effectively override certain module styles.
Comment | File | Size | Author |
---|---|---|---|
#21 | add-css-last-455426-21.patch | 1.45 KB | emattias |
#18 | css_injector_last_loaded_455246_18.patch | 646 bytes | BTMash |
Comments
Comment #1
pebosi CreditAttribution: pebosi commentedi've got the same problem. but changing module to theme works for me:
to
regards
Comment #2
philbar CreditAttribution: philbar commentedYep, here is my css:
I can't even override garland's color css.
Comment #3
pebosi CreditAttribution: pebosi commentedtry setting the css injector rule to only "screen"
regards
Comment #4
Robin van Emden CreditAttribution: Robin van Emden commentedSame problem, tried #3 suggestion, still injection before other css.
Comment #5
Robin van Emden CreditAttribution: Robin van Emden commentedComment #6
chrisschaub CreditAttribution: chrisschaub commentedWouldn't suggestion #1 be a good fix to commit? Seems very sound, and if the module weight is set high as well then it should be last in the theme layer too?
Comment #7
lee20 CreditAttribution: lee20 commented+1 for #1!
-1 for #3
It's really a pain to try to override module css.
Comment #8
ryumkin CreditAttribution: ryumkin commented#1 + #3 = works
Comment #9
escoles CreditAttribution: escoles commentedSetting to 'screen' only (#3) seems to work on my install. But wouldn't that still be a bug?
CORRECTION: #3 does NOT work unless you select "Pre-process HTML" on the rule edit screen. (If you don't select "pre-process", the rule actually comes FIRST.)
Comment #10
leon85321 CreditAttribution: leon85321 commentedconfirmed #9 is right, will need to set to 'screen' only and the 'preprocess' needs to be checked!
Now it is loaded last so themes css are overridden.
Thanks!
Comment #11
lefnire CreditAttribution: lefnire commented+1, please fix ala #1. One can only fool the theme so many times with !important and class/id-specific selectors.
Comment #12
mpotosnak CreditAttribution: mpotosnak commented#1 also fixed issues fixed issues between wysiwyg and css injector. By selecting use theme css, the css injector code is now included.
Yay!
Comment #13
klonosI take it that #1 refers to line 37 in the
css_injector.module
file (6.x-1.4, 2010-Mar-08). Right?If so, then people need to know that it changed a bit (more then a year has passed since #1). So, it needs to be changed from:
drupal_add_css(file_create_path(_css_injector_rule_path($css_rule['crid'])), 'module', $css_rule['media'], $css_rule['preprocess']);
to:
drupal_add_css(file_create_path(_css_injector_rule_path($css_rule['crid'])), 'theme', $css_rule['media'], $css_rule['preprocess']);
It would be great if there was a (per-rule perhaps?) option/checkbox to 'Behave as theme CSS rule'. Then the above line of code could be changed to something like:
drupal_add_css(file_create_path(_css_injector_rule_path($css_rule['crid'])), $css_rule['behavior'], $css_rule['media'], $css_rule['preprocess']);
I guess there needs to be some updating of the
css_injector.install
file as well to include something like this:...and the
css_injector.admin.inc
file to include something like this:But I honestly wouldn't know (not a module developer). Thanx in advance for considering this one.
PS: this will never get in if it remains a 'support request'. Changing it to 'feature request'.
Comment #14
d.cox CreditAttribution: d.cox commented#9 +1
Comment #15
rfayThe D7 version does this, but the way it uses is not available in D6.
However, sweaver does this in D6, so following its technique would work.
Comment #16
jason.fisher CreditAttribution: jason.fisher commentedIn Drupal 6, I believe this method may need to be used to ensure injector CSS is last:
drupal_set_html_head('<style type="text/css">' . $css . '</style>');
Injector is rather odd to use as first CSS .. end up needing way more !important markers than you should.
Comment #17
Denny CreditAttribution: Denny commented#10 works, thx!.
Choose 'screen' and check 'preprocess' and it works.
Comment #18
BTMash CreditAttribution: BTMash commentedWhile I haven't tried adding any of the other features on where the css should be loaded, I did want the css injector to be one the last things loading and for the D7 version, I am attaching the patch that seems to do the trick. I've tried it on a couple of my sites and it seems to be working just fine. However, I won't change the version since a larger focus seems on the 6.x version.
Comment #19
ednique CreditAttribution: ednique commentedI had similar problems...
css_injector_last_loaded_455246_18.patch worked just fine...
to be sure I changed the weight to 200...
thanx BTMash
Comment #20
boclodoa CreditAttribution: boclodoa commentedI've been using #1 + #3 + #9 for a while, but with the nitobe theme that does not work. I think the reason is that they declare as "screen" their style.css file. So what I did is to change the line
to
in the file nitobe.info
by now is working, I'll tell you if I see troubles with this change.
Comment #21
emattias CreditAttribution: emattias commentedHere's a patch that makes css injector add css the same way that sweaver does it. This will make sure that it's added last in pretty much all cases.
Comment #22
rfayNote that D7 already does this...
Also note that this change could cause unexpected changes for a large number of users, and D6 is near end of life. I'd be cautious about doing this.