2

I have a view that display data from nodes (it's a listing of books). Next to each rows, I need to display some icons that represent different category per book. Per example, a book could have the categories "For young adults, comic, black-white".

All the categories are in a taxonomy, and when the node is created, we select the ones we need.

Now displaying the field of the categories in the view doesn't work if I have more than one category selected.

I created a relation, allowing me to retrieve the images, but it only displays the first category selected.

How would I be able to display all of them ?

Thanks!

3

If you are willing to use Display Suite then you can get the kind of result you are asking for with configuration only (but with some limits on flexibility). The other alternative would be to do something with Views PHP.

The steps for configuring Display Suite to show taxonomy terms as images (from an image field you've added to the taxonomy) are:

  1. Create a view mode for your taxonomy (or reuse, say, the tokens view mode). This view mode needs to show just your image image field. You can format it here, e.g. to a thumbnail or whatever works for you.

  2. Create a view mode for your content type (or content types if more than one is involved). You could use the standard teaser view mode or add a custom one for this purpose. Add the fields you want from your node and also add the term reference field.

  3. For the term reference field select the Rendered taxonomy term FORMAT option. This then gives you a choice of view mode for rendering the term. Select whatever you used in step 1.

  4. In you View select Show: Content | Teaser under the FORMAT section. (If you've made a custom view mode, then replace 'Teaser' with the name of your custom view mode.)

By using the Content option you lose some of the flexibility of using the Fields option Views. If that's an issue you may need to go the Views PHP route. Although, if it's a case of doing the sort of thing that Views does with Rewrites, you may be able to do some or all of by using Display Suite code fields or block fields.

This approach, of course, also allows you to use the images for taxonomy terms (single or multiple) in your default view mode as well. If you're new to Display Suite, this might be a fairly tricky configuration task - but once you're used to DS it's a pretty quick job.

  • I ended up using "Views PHP". Thanks! – Ebpo Mar 21 '13 at 13:18

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.