Closed (fixed)
Project:
CSS Injector
Version:
6.x-1.1
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
11 Mar 2008 at 12:25 UTC
Updated:
16 Oct 2009 at 10:00 UTC
when i try to override a css rule set by the theme (i use garland) it doesn't work, since garland's stylesheets are included after the one created by css injector.
...
<link type="text/css" rel="stylesheet" media="all" href="/~rupi/bidala.org/zufall/drupal-6.1/sites/all/files/css_injector_1.css?S" />
<link type="text/css" rel="stylesheet" media="all" href="/~rupi/bidala.org/zufall/drupal-6.1/modules/taxonomy/taxonomy.css?S" />
<link type="text/css" rel="stylesheet" media="all" href="/~rupi/bidala.org/zufall/drupal-6.1/sites/all/modules/image/contrib/image_attach/image_attach.css?S" />
<link type="text/css" rel="stylesheet" media="all" href="/~rupi/bidala.org/zufall/drupal-6.1/themes/garland/style.css?S" />
...
i think this problem is somewhat hard to solve, as it's not possible to tell drupal_add_css() in what order to include the stylesheets.
workaround: set media to "screen"
Comments
Comment #1
rangermeier commentedit works if you hand over the injected stylesheets as they were a theme's stylesheet instead of a modules:
line 20 in css_injector.module has to change from
to
i'm not sure wheter this is a valid solution, and what implications it has to include a module's stylesheet pretending it is a theme.
Comment #2
gertieiv commentedhello,
i changed the code as suggested.
one time it works perfect and the stylesheet is the last in the row
an other time it doesn't work, and injected stylesheet isn't the last sheet in the row
http:///www.sintleo.be/
is there anything i do wrong?
geert
Comment #3
gertieiv commentedit's ok now
the first time i didn't see i had to set the media to screen
geert
Comment #4
add1sun commentedHm, kinda torn on this since "the Drupal way" is to let the theme have the last crack. For now, I'll add documentation about how to use the CSS !important declaration rather than actually modifying things to force this. I'll mark this postponed so we have more time to mull a more strong-handed approach over.
Comment #5
stephthegeek commentedAck, please don't use !important -- it's a hack and can have serious accessibility and cross-browser repercussions.
I would think that if you're using CSS Injector, it will be intended to either be a ThemeLite(tm) or to supplement/alter something IN a theme, so the idea of putting it after the theme's CSS makes sense to me. It feels like a special case... but y'all are the "Drupal way" experts more than I am :)
Comment #6
rsvelko commentedIf we want the theme to be the last one always and still want to use this module to override css from within the drupal UI there is only one option I see:
- let the css_injector module create a "custom_overrides.css" file in the theme's folder !
This means:
- a new setting for css_injector - which themes to touch
- a possible security issue - when a module would read and write a file in a theme ... (quite the same as the module 2 module case)
- a massive patch and a new standard for all drupal themes - to include this custom_overrides.css file - think of it like the conf.d/ of apache (actually Dries's acquia_marina theme uses the same approach since several months...)
So the final proposal is for a new convention for a sub-folder named css_override.d/ in every theme ...
---------------------------
There is also the option number 2: use the
html tag in the head of each html document - so called inline css... Is this ok?Comment #7
rsvelko commentedI read in the api docs that for 6.x there is nothing said about inline css, but for 7.x. there it is... You can add a css string inline....
How is this done in 6.x.?
It always comes last, right? So it should be the solution.
Comment #8
rsvelko commentedactually one of the reasons why in 7.x they have implemented "inline" is because of css_injector - see here:
http://drupal.org/node/259368
Comment #9
rsvelko commentedSo, to sum up:
5.x, 6.x - use the html_head api function and change the places of the $head and $styles tpl variables (or modify your theme's css at the end OR use a child theme... OR use !important)
7.x - see if the new drupal_add_css is already used properly in the current 7-dev of css_injector and live happily
Marking fixed.
Comment #10
rsvelko commentedmy personal favourite way seems to be "modifying the style.css at the end" and if there is a need maybe separate those overrides in a custom_overrides.css file sourced by the theme's .info file....
Comment #11
rsvelko commentedIf one asks "What is css_injector good for then?" the answer is "to inject css on properties not mentioned in the theme or to override thme with !important if lucky" :)
Comment #12
rsvelko commentedfor the protocol - one final way to override the theme is to use the http://drupal.org/project/style_settings module