How do you override the drupal css in drupal 5

This code no longer works

function phptemplate_stylesheet_import($stylesheet, $media = 'all') {
if ($stylesheet != 'misc/drupal.css') {
return theme_stylesheet_import($stylesheet, $media);
}
}

There is no longer a misc/drupal.css file - the default css is now in modules/system/default.css
But i cant work out how to override it

My problem is the blocks are wider than my sidebar, i used the bluemarine theme and made a 2 column css layout

Also when building my css based theme i had to add these css rules to stop the profile and create content forms appearing at the bottom of the page

.profile {
clear: none;
}

.node-form .standard {
width: auto;
clear: none;
}

Hope that helps someone

Comments

zach harkey’s picture

Take a look at this handbook page: Converting 4.7.x themes to 5.x. It's loaded with good tips on this, but here is the relevant excerpt:

There is also a new variable available in phpTemplate now, $css, which is an array of all the CSS files for the current page. $styles still holds the actual HTML to load the CSS files, but if at the theme level you want to swap out certain CSS files (like drupal.css for example), this is very easy.

  // print $styles;
  // we don't need to print out $styles since we want to take out drupal.css

  unset($css['core']['misc/drupal.css']);
  print drupal_get_css($css);

-zach
--
harkey design

: z

hapworth’s picture

I am trying this and have trie it in several ways. I'm trying to get rid of defaults.css... I've tried the following:

unset($css['core']['misc/defaults.css']);
unset($css['core']['modules/system/defaults.css']);
unset($css['core]['system/defaults.css']);

however, print_r($css); at the bottom of the page still shows defaults somehow getting through and the styles are still there.

Any help with this?

-gary

zach harkey’s picture

You are right hapworth. When I print_r($css) in my page.tpl.php I find no 'core' key in the $css array.

While this is undocumented anywhere, the following technique seems to accomplish the desired results.

To flat-out remove 'defaults.css', in page.tpl.php I would

replace

  print $styles;

with

  // Redefine $styles to not include defaults.css
  unset($css['all']['module']['modules/system/defaults.css']);
  $styles = drupal_get_css($css);
  print $styles;

Alternatively I could provide my own replacement stylesheet. For example, if I don't like all of the default primary and secondary tabs styling, which are styled in system.css, I could use

<?php 
  // Redefine $styles to not include defaults.css
  unset($css['all']['module']['/modules/system/system.css']);
  $styles = drupal_get_css($css);
  print $styles;
?>
<style type="text/css" media="all">@import "/<?php print $directory ?>/system.css";</style>

-zach
--
harkey design

: z

mattrock’s picture

Is it possible to execute the stylesheet exemption code in the template.php file? I see that zen.css now loads stylesheets in template.php instead of page.tpl.php.
Code from Zen template.php

// These next lines add additional CSS files and redefine
// the $css and $styles variables available to your page template
// We had previously used @import declarations in the css files,
// but these are incompatible with the CSS caching in Drupal 5
drupal_add_css($vars['directory'] .'/layout.css', 'theme', 'all');
drupal_add_css($vars['directory'] .'/icons.css', 'theme', 'all');
drupal_add_css($vars['directory'] .'/zen.css', 'theme', 'all');
    $styles = drupal_get_css($css);

It would be nice to be able to keep all of these declarations together.

robomalo’s picture

So aggregating and compressing CSS files still work properly after "unsetting" default/system/module styles? Am I correct believing that Drupal caches whatever your final output of $styles is? From the commented section in the post above, it seems that @imports inside of a stylesheet added with drupal_add_css() do not get added to the cache.