Posted by cschaub on May 6, 2009 at 4:10pm
| Project: | CSS Injector |
| Version: | 6.x-1.4 |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Issue Summary
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.
Comments
#1
i've got the same problem. but changing module to theme works for me:
drupal_add_css(file_create_path($css_rule['file_path']), 'module', $css_rule['media'], $css_rule['preprocess']);to
drupal_add_css(file_create_path($css_rule['file_path']), 'theme', $css_rule['media'], $css_rule['preprocess']);regards
#2
Yep, here is my css:
<link type="text/css" rel="stylesheet" media="all" href="/modules/node/node.css?O" />
<link type="text/css" rel="stylesheet" media="all" href="/modules/system/defaults.css?O" />
<link type="text/css" rel="stylesheet" media="all" href="/modules/system/system.css?O" />
<link type="text/css" rel="stylesheet" media="all" href="/modules/system/system-menus.css?O" />
<link type="text/css" rel="stylesheet" media="all" href="/modules/user/user.css?O" />
<link type="text/css" rel="stylesheet" media="all" href="/sites/all/modules/cck/theme/content-module.css?O" />
<link type="text/css" rel="stylesheet" media="all" href="/sites/default/files/css_injector_1.css?O" />
<link type="text/css" rel="stylesheet" media="all" href="/sites/all/modules/tagadelic/tagadelic.css?O" />
<link type="text/css" rel="stylesheet" media="all" href="/sites/all/modules/faceted_search/faceted_search_ui.css?O" />
<link type="text/css" rel="stylesheet" media="all" href="/sites/default/files/color/garland-29b97441/style.css?O" />
I can't even override garland's color css.
#3
try setting the css injector rule to only "screen"
regards
#4
Same problem, tried #3 suggestion, still injection before other css.
#5
#6
Wouldn'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?
#7
+1 for #1!
-1 for #3
It's really a pain to try to override module css.
#8
#1 + #3 = works
#9
Setting 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.)
#10
confirmed #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!
#11
+1, please fix ala #1. One can only fool the theme so many times with !important and class/id-specific selectors.
#12
#1 also fixed issues fixed issues between wysiwyg and css injector. By selecting use theme css, the css injector code is now included.
Yay!
#13
I take it that #1 refers to line 37 in the
css_injector.modulefile (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.installfile as well to include something like this:'behavior' => array('description' => 'Whether this CSS rule should behave as a theme rule',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 1),
...and the
css_injector.admin.incfile to include something like this:$form['behavior'] = array('#type' => 'checkbox',
'#title' => t('Behave as a theme CSS rule'),
'#default_value' => $rule['behavior'],
);
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'.
#14
#9 +1
#15
The 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.
#16
In Drupal 6, I believe this method may need to be used to ensure injector CSS is last:
<?phpdrupal_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.
#17
#10 works, thx!.
Choose 'screen' and check 'preprocess' and it works.
#18
While 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.
#19
I had similar problems...
css_injector_last_loaded_455246_18.patch worked just fine...
to be sure I changed the weight to 200...
thanx BTMash
#20
I'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
stylesheets[screen][] = styles/style.cssto
stylesheets[all][] = styles/style.cssin the file nitobe.info
by now is working, I'll tell you if I see troubles with this change.