I'd like to find a way to easily subtheme core themes, mainly to help newbies get their first taste of theming. In my tests so far, it seems that I have to copy the css, js, and images as well.

I've created /sites/all/themes/garlin/garlin.info. (I'm calling my test theme "Garlin"). Here is what is in it:

name = Garlin
description = Theme based on bluemarine
core = 6.x
engine = phptemplate
base theme = bluemarine

There is no CSS added by the theme, although the markup is controlled by bluemarine's .tpl.php files.

If I change base theme = bluemarine to base theme = zen or base theme = genesis then the base theme's css shows up.

Is there anything special I need to do when subtheming a core theme? Or do I have to copy these other files (css/js/images) into my subtheme, thus losing the benefit of subtheming?

Comments

trevortwining’s picture

You need to have stylesheet declarations present in your parent info file for it to work.

I tested using the following code

First I used a subtheme of bluemarine that I called redmarine. (original, I know)

Next I used the same info file as you did, but changed the names appropriately.

Then I added the following stylesheet declaration to the bluemarine.info file (parent theme)

stylesheets[all][] = bluetest.css

Next, I created the bluetest.css file, which only consisted of one declaration:

body {
  background-color: red;
}

I then enabled the bluemarine theme. This cleared the cache and rebuilt the theme registry. Then I enabled the redmarine subtheme, and I got the same results. I repeated this by using the clear cache option under Admin-->Site Configuration-->Performance

To me, this means that you need to use the stylesheet inclusion method in the themes, and not just rely on a style.css file to be picked up by the subtheme.

Trevor Twining
CivicActions (http://civicactions.com)
Changing the world one node at a time.

Trevor Twining
Freelance Drupal Dev
Theme/Modules/Sitebuilding

nadavoid’s picture

Thanks Trevor, I'm more on the right track now. I've determined some more things.

If the parent theme uses the default style.css file (regardless of whether it's explicitly defined), it will not get picked up by the subtheme. period. (makes me sad.)

If the parent theme uses any css that is not standard, such as:

stylesheets[all][]   = bluetest.css

or

stylesheets[all][]   = style-copy.css

then it WILL get included in the subtheme.

Could someone confirm that this observation is correct? Or am I missing something?

If this is correct, then the only trustworthy way to override a core theme (since they will of course use style.css) is to copy that style.css to your subtheme. That will of course mean also copying to your subtheme all the images it references.

Now that I've gotten this far, I realize that this applies not just to core themes, but any theme that uses the default style.css file. Genesis and Zen neither use this file, and define their own custom stylesheet names. Thus they get inherited by the subtheme. This is probably documented somewhere, but I couldn't find it.

Jeff Burnz’s picture

This has been my experience also, I assume its a bug because even if you explicitly declare style.css in the parent theme it does not get included by the subtheme, but as you point out style-copy.css does.

According to the docs I can find all style-sheets explicitly declared in .info should be included by the subtheme automatically - therefor this is either a bug or needs documentation/clarification. I would suggest filing an issue, and testing D7 to see if this is still the case, since a fix would probably need to be made for D7 first, then backported to D6.

rhialto’s picture

I am glad I found this discussion. I'm reading a Drupal book and following examples, and had spent awhile tearing my hair out because I followed instructions precisely and the parent theme css was *not* getting transferred over to the sub-theme.

I'm thinking this failure to see the parent css must be a relatively recent bug, as I assume the author of the book tested his code and it worked in an earlier version on Drupal 6.

jffmrk’s picture

I have Drupal 6.8 installed and created a sub theme. The parent theme has a style.css file that is included when the sub theme is used. If your sub theme has a style.css file, the parent theme's style.css will not be included. If you have additional css files in the sub theme, make sure you name them something other than style.css. The Garland parent theme and Minneli sub theme is a good example of this.

I found this page about sub themes that was helpful - see the 2nd comment for clarification.
http://drupal.org/node/171209

Hope that helps.

Jeff Burnz’s picture

Yea, what I found is that if you declare any other stylesheet (and it exists) then style.css gets included, so Minelli has minnelli.css, but if you have no other stylesheets declared in the subtheme, style.css is not included - that is what I think is either a bug or a documentation issue. The docs clearly state that all stylesheets defined in the parent theme are included in the subtheme.

FWIW I dont think its really a big deal, since you are going to have another stylesheet for your subtheme in order to make it different.

sinasalek’s picture

Thanks, that helped

sina.salek.ws, Software Manager & Lead developer
Feel freedom with open source softwares

Bevan’s picture

To work around the broken style.css inheritance, without having to copy all of the parent theme's CSS and images, put the following code snippet in your sub-theme's template.php file.

// Sub-themes cause parent theme's style.css files to be ignored.
// Manually add each parent theme's style.css.
// @see drupal.org/node/347328#comment-1703058
foreach ($GLOBALS['base_theme_info'] as $parent_theme) {
  drupal_add_css($parent_theme->stylesheets['all']['style.css'], 'theme');
}

This way you won't need to copy styles and images everytime you update the parent theme. Yay! No more dead kitties! :)

Don't hack core. (Or contrib)

Bevan/
http://CivicActions.com

Jeff Burnz’s picture

Margo52’s picture

please send me at least the version of my website (umpire2umpire.com) that you have currently, so that I may work on it more.
Thank you

Michal

Sorry for offtopic...