Style depending on taxonomy term

Joined: 02/27/2010
User offline. Last seen 1 year 42 weeks ago.

Hello.
I've been struggling for days with a particular subject and now I come asking for help.

This is my scenario in a test site:
I have a taxonomy vocabulary named: Colors
Colors terms are: Blue, Green, Yellow.
These terms apply only for blog entries, so I did a test adding two posts for term Blue, two posts for term Green and two posts for term Yellow.
The resulting URL aliases are: (generated by pathauto module and configured for my specific needs)
colors/blue
colors/blue/first-blue-post
colors/blue/second-blue-post
colors/green
colors/green/first-green-post
colors/green/second-green-post
colors/yellow
colors/yellow/first-yellow-post
colors/yellow/second-yellow-post

What I want to achieve is that: colors/blue and their children (colors/blue/*) have a common background (let's say a blue background for all of them). The background must be applied in the term page and in each of the post entries related to that term.
The same idea applies for green and yellow: the "green term" page as well as its corresponding post entries must have the green background and a fixed title. And so on with the yellow term.

In other words, I want to "stylize" each category of the blog based on the taxonomy term.

How can I achieve this?

I really appreciate your help.

Thanks in advance.

Joined: 12/20/2009
User offline. Last seen 1 year 37 weeks ago.
It might be possible

I am doing something similar on a site in development now. They key for me was to render custom classes and once I had that I could style per taxonomy term. It opens the door to custom colors, headers, backgrounds etc...

Here are a few articles that explain how to get the custom body class:

http://drupal.org/node/204482 -- see the bottom of the page where they figure out the correct code for taxonomy
http://mydrupalblog.lhmdesign.com/classes-almost-e...

If you are using the zen theme, you probably already are getting these custom classes. In my case I normally use a 960 grid theme so I just added the code as suggested.

I hope this helps.

Joined: 02/27/2010
User offline. Last seen 1 year 42 weeks ago.
Thanks!

Thanks highrockmedia!
The content on the first link was very helpful. I think I got it right now.

Thanks for your help.

Regards.