I have a view with two content types. I can use views conditional to add a field depending on the content type, but how do I add a style to the entire row of content depending on the content type, for example I want content of type Article to have a class so that I can color it blue, while content of type "statistical data" will be white .


In the left top, behind format you can click the settings button. This shows you the style options dialog, where you can define a row class.

This class fields accepts views tokens (though does not provide the overview of them). So you should add a field for the content type, hide it from display if you please. Discover the token name of this field by checking the rewrite section and finally place this token in the row class field.

In my example I use the value of a php field to add row classes:

enter image description here

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.