1

I added the field_tags to my view.

Now I want to add a the tag name as a class name, so I can colour each tag differently.

ex:

<div class="tag1">tag1</div>
<div class="tag2">tag2</div>
<div class="tag3">tag3</div>

Unfortunately, unchecking display all values in same row is not an option for me since I need to limit the view to 4 results.

Therefore, somehow I need to be able to loop through them and attach each of them the tag name as a class name.

How can I achieve this?

1

The only work-around solution that I can think of would be to:

Create a separate view for the tags.

Then there I will be able to uncheck display all values in same row.

Re-write field to <div class="{{ field_tags }}"> {{ field_tags }} </div>

Then use View Fields View to insert the Tags view as a field in my other view and pass the nid as contextual filter.

Probably not the best solution, so if anyone has a better one I'd love to hear it.

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.