On the front page a list of teasers is shown for different content types. For one of these content types I want to use different css depending on the value of the taxonomy term.

  • Content type name : "messages"
  • taxonomy values in list "type": offer, want, general
  • I want a different background color for "messages" depending on the value of the taxonomy term "type".

In a view for just this content type I could add a CSS-class to the taxonomy field. But the front page view shows different content types, so teasers are shown, not a list of fields.

How could I change the css-class depending on that particular taxonomy field ? (for the field only of for the entire teaser)

Where to start ?

  • 1
    Did you try hook_preprocess_HOOK? api.drupal.org/api/drupal/… Aug 24, 2022 at 4:11
  • That would require some programming. I am not sure if I know enough - I'll have to study :) and give it a try.
    – sigridt
    Aug 25, 2022 at 10:04


Your Answer

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

Browse other questions tagged or ask your own question.