Is there anyway to tweak Drupal 5.x CSS without changing core source files?

I tried adding a custom module "css_tweak" which does a drupal_add_css() for a new CSS file - That doesn't work because it will never be loaded last in the list of CSS files and therefore will be overridden by the theme's CSS.

Is there any way without changing core source?

A "weight" argument on drupal_add_css() may be an easy way to solve priority of added css files?

Comments

drpratten’s picture

The use case for this request is this. I am using Garland and wish to tweak just one or two aspects of it.

I do not wish to alter the source of Garland as that will complicate upgrades.

Now having read http://drupal.org/node/92877 I realise that drupal_add_css() is unlikely to ever get a weight argument.

OK - a weight on drupal_add_css() would have made an easy solution to this - but my original question remains.

How can I tweak Garland without altering source files?

cog.rusty’s picture

A usual method is to make a copy of Garland with a different name and hack that one as a different theme.

A small problem are core updates, but you can easily figure out the changes by going here and looking at "Diff to previous":

http://cvs.drupal.org/viewcvs/drupal/drupal/themes/garland/style.css

ap’s picture

Use the css import command to import a separate css file at the end of the style.css. You can place all your css modifications in this file. Since they are defined after the other css definitions any of them that override previous definitions will take precedence. Also in the case of upgrades all you have to do is remeber to put the import command back in.

ap’s picture

It's better to test before one speaks (or writes). My suggestion does work but not as I had suggested. The CSS @import command is not evaluated if it occurs after other CSS definitions. This means that any @import commands must be located at the beginning of a CSS file.

This is not the end of the world, however, at least in my case. The reason I wanted to put it at the end of the file was to override previous definitions based on the CSS cascading rules. In my case, however, I don't want to change Site-Wide settings but apply some style changes to certain content elements. This can be done via class or ID definitions which are independant of the main theme definitions. Thus, their placement is irrelevant.

Perhaps for future theme development this need should be considered. One need only include a css file in the template that is located at the end of the include order. Initially it could be empty or even non-existant and if a site-manager wants to make styling changes they could be placed in this file and there is no need to alter the original theme source-code.

dshaw’s picture

You can create a theme based on garland by making a subdirectory in it and overriding the bits you want to change. This is how the minelli theme is done. Have a look at the theme guide. Check out how Box Cleanslate is made from Box Grey.