I want to implement different font colors on my taxonomy terms. I have installed and configured my color module version 7.x-1.0-rc1 but still I can't find any result.

  • How many taxonomy terms do you expect? and are you planing for automated colors rather than fixed colors for each term? Oct 10, 2013 at 5:32
  • I actually want a fixed color for each item. I have 2 terms, for my "status" taxonomy vocabulary Oct 10, 2013 at 5:36
  • Why don't you use css then. Each term would have its own class you can use that to set a color. Oct 10, 2013 at 8:14
  • Sound simplier.How can I achieve that? what css page will I edit and where will I declare the classes on each taxonomy term? Oct 10, 2013 at 8:18
  • If you look at the generated html code you would see the classes for the terms. You can use that classes to define the color in the css of your theme. Oct 10, 2013 at 8:19

1 Answer 1


Here are steps you need:

  1. Install jQuery Colorpicker module.

  2. In the vocabulary for terms for which you want to add colours, add a jquery color picker field.

  3. So when you create each term, you also select a colour for it while creating. in this way each taxonomy term will have a colour.

  4. now in the taxonomy term preprocess template, write something like this to grab the color and pass it as variable.

    function themename_preprocess_taxonomy_term(&$vars) {
      $colour_code = $vars['taxonomy_term']->field_yourcolorfieldname['und'][0]['value'];
      $vars['colour_code'] = $colour_code;

Then copy the taxonomy-term.tpl.php to your theme folder, and you will be having $colour_code variable giving you the colour code of the term. you it to provide an inline css.

Remember, if overriding taxonomy term template is not what you need, or you want to have it elsewhere, whenever you get $term object, you can get the colour code through $term->field_yourcolourfieldname['und'][0]['value'].

  • this is cool and clean!
    – arpitr
    Oct 10, 2013 at 6:45
  • Where can I find this "now in the taxonomy term preprocess template" Oct 10, 2013 at 8:36
  • copy /modules/taxonomy/taxonomy-term.tpl.php to you theme. Them modify the copied taxonomy-term.tpl.php file
    – Neo
    Oct 10, 2013 at 8:38
  • And for your preprocess funciton, you need to implement the themename_preprocess_taxonomy_term(&$vars) function i wrote in your theme's template.php file. Ofcourse replace 'themename' with the name of your theme.
    – Neo
    Oct 10, 2013 at 8:39
  • I dont have a taxonomy folder in my modules folder Oct 11, 2013 at 5:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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