Allow overriding theme

shirster - March 10, 2007 - 11:20
Project:Taxonomy Theme
Version:5.x-1.1
Component:Code
Category:feature request
Priority:normal
Assigned:Mapache
Status:by design
Description

Hi,

Thanks for this great module, is it possible to create an option to override a theme instead of replacing it completely?

Say I have a sports section and a food section on my site and my default theme is theme_A; I would like the food section to have different font colors but everything else should remain the same as the sports section. Now if I use this module to assign a theme_B to the food section, the header would read :

<style type="text/css" media="all">@import "/sites/all/themes/theme_B/style.css";</style>

But what I would like is :

<style type="text/css" media="all">@import "/sites/all/themes/theme_A/style.css";</style>
<style type="text/css" media="all">@import "/sites/all/themes/theme_B/style.css";</style>

So that I only need to put some color variations in theme B's css file, instead of a whole copy of theme_A/style.css. Also, when I need to change some css settings for the whole site, I don't have to change both css files.

Thanks in advance !

#1

Mapache - June 19, 2007 - 05:28
Assigned to:Anonymous» Mapache
Status:active» by design

You don't want this module to do that. Simultaneously loading multiple themes is not possible with respect to the php that generates the page, and likely to produce bad results from the the CSS side.

Instead, you should create a theme that descends from the other theme. If you want theme_B to override part of theme_A, but otherwise be the same, create a folder called theme_B inside theme_A, and in theme_A/theme_B/style.css import theme_A's style.css and override whatever you want, like so:

@import url('../style.css');

body {
    color: blue;
}

CSS uses the last value you define for a property, so anything in theme_A/theme_B/style.css will replace anything in theme_A/style.css.

Drupal recognizes this setup, so if you go into the Themes section, you'll see both theme_A and theme_B listed as separate themes which you can enable and use.

 
 

Drupal is a registered trademark of Dries Buytaert.