How would one go about trying to accomplish the following under Views in D7:

Say I have four different content types (apples, oranges, kiwis, and mangoes) which are culminated into one view listing them all on a single page.

I'd like to try and add a CSS class to both apples and kiwis that is unique to each (for example, all apples having a class of "red" and all kiwis having a class of "fuzzy") but I do not want to add classes to mangoes or oranges.

How would I let Drupal know to add these classes based on their content types?

  • Are the fruit classes (i.e. "fuzzy" & "red") based on a content field or taxonomy field? Are they predefined? (i.e. not user generated)
    – Shawn Conn
    May 22, 2015 at 18:52

1 Answer 1


You can use template_preprocess_views_view_fields function in order to do it.

Your Answer

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

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