We have a number of different themes on our website as we have different departments with different color styles. However, the only thing that changes are the colors of the sidebar and which menu is displayed on the sidebar; the layout of these pages remain the same almost exclusively. It seems as though having 16 different themes, which we do, is unnecessary if these are the only things changing (sidebar color and menu).

Are there any good modules which could achieve this functionality (changing color and menu depending on department) without having all these different themes? Or are themes the only/best way to go to achieve this functionality? Also is having this many themes the average or is that a lot?

  • there are many different ways this could be achieved without so many themes - they would be based on how the system determines the departments (by url, by role, by user, by user field setting, etc). Once that is known, it will be easier to guide you to a solution... and that seems rather excessive to me for number of themes...
    – Geoff
    Jun 26, 2015 at 19:23
  • We currently determine which theme is attributed to a page by what the URL is using ThemeKey. The URL is determined, using Pathauto, by a taxonomy term on each page and then the title of the node. The whole site is sort of daisy chained together off of the section taxonomy on each node. I'm not sure that's good or normal....
    – Travis
    Jun 26, 2015 at 19:26

1 Answer 1


There are 16 different departments so 16 different colors are needed. Create one theme for all of them. In your .css file create 16 classes and in each one set a custom background color. Like this

.dp—i{ background-color:#abcdef !important}

Now using preprocess functions, and based on the department add the css class to the page component. If it is a block use preprocess_block, if it is region use preprocess_region. By checking the department and adding approprite css class to the class array it will work

  • OK, creating the different CSS classes within the same class makes sense to me. I'm not familiar with preprocessing, unfortunately. Do you have any good resources on what that means and how to utilize it?
    – Travis
    Jun 27, 2015 at 20:40
  • Talking about preprocessing functions takes hours! These functions are called just before building every element of the page. In drupal every thing is array, so using preprocess functions you can modify the array of components of the page. There are hunderds of documentation about preprocessing on internet just search for.it. to start off watch [this][1] video and also search for similar ones on youtube. [1]: buildamodule.com/video/…
    – M a m a D
    Jun 27, 2015 at 20:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.