Forcing a sub-theme to include parent theme's css first
ravinggenius - March 14, 2007 - 01:07
I am developing my very first Drupal theme. It itself is really a slightly-styled 'shell' theme, and I have several sub-themes, each depending on the parent theme for layout. These are the files I would like to add in the following order for all sub-themes. For instance:
<?php
if (subTheme) {
unset $css['themes']['mytheme']['subtheme'];
}
drupal_add_css('mytheme/style.css', 'theme', 'screen');
if (subTheme) {
drupal_add_css('mytheme/subTheme/style.css', 'theme', 'screen');
}
if (userBrowser == 'IE') {
drupal_add_css('mytheme/style-ie.css.php', 'theme', 'screen');
}
drupal_add_css('mytheme/wallpaper.css.php', 'theme', 'screen');
?>I need to add the sub-theme css after the parent theme css.
Another thing along the same lines, I also need to add the style-ie.css.php with conditional comments:
<!--[if lte IE 6]>
<link rel="stylesheet" href="mytheme/style-ie.css.php" type="text/css" media="screen" />
<style type="text/css" media="all">@import "mytheme/style-ie.css.php";</style>
<![endif]-->I wanted to put all of this code, or as much as possible, in the main theme's template.php file so it would be automatically included for each subtheme.

I guess I never actually
I guess I never actually posed a question; is this the best way to implement this, or should I be looking for something else? Is there a function or variable that tells me if I am using a subtemplate (and hopefully which one!).
I really need some help with this, if even a just a reference.
I was about to ask the same
I was about to ask the same sort of question...
but I've figured out a way to do it, or at least to do what I need, which is for the subtheme to override only parts of the parent theme's CSS.
Put this at the top of your subtheme's style.css:
@import "../style.css";