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

rangermeier’s picture

it 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

      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']);

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.

gertieiv’s picture

hello,

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

gertieiv’s picture

it's ok now

the first time i didn't see i had to set the media to screen

geert

add1sun’s picture

Status: Active » Postponed

Hm, 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.

stephthegeek’s picture

Ack, 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 :)

rsvelko’s picture

Status: Postponed » Needs review

If 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?
rsvelko’s picture

I 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.

rsvelko’s picture

actually one of the reasons why in 7.x they have implemented "inline" is because of css_injector - see here:
http://drupal.org/node/259368

rsvelko’s picture

Status: Needs review » Fixed

So, 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.

rsvelko’s picture

my 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....

rsvelko’s picture

If 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" :)

rsvelko’s picture

for the protocol - one final way to override the theme is to use the http://drupal.org/project/style_settings module

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.