0

Hi i have created a view that displays recently viewed items. This displays the 'teaser' display mode of a custom content type. This content type has a field 'favorite'.

What i want is to add a css class to the outer div (on the teaser div or de col-... generated by the view). But only if it is a 'favorite'.

I have created the view in the Drupal backend I could probably do in a custom module. I just want to check if it is possible without any programming.

1 Answer 1

1

You could try this but may depend on your 'favourite' field output

If you click on "Format > settings" when editing your view you'll see a "Row class" field. In there you can put the replacement pattern for your favourite field.

So if its populated it will add the field value as a class to the view-row div. And you can use this to know if the field has content

If that's not going to work because the field content isn't suitable as a class then you could preprocess the node view and add a class yourself in the attributes array

1
  • Thanks for your answer. It is a field form the flag module, so I guess it's not working because of this. I'm going to preproces it I hadn't thought about this before. Thx Jun 8, 2018 at 9:55

This site is temporarily in read-only mode and not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .