0

I have a list of possible taxonomy terms (vocab is called Categories) that can be referenced on a given node. For this particular vocabulary, I have a custom field called field_icon_class. The intention here is to make use of CSS Sprites, so when the terms for the page are rendered, they hopefully get printed out with the field as the CSS Class for the individual taxonomy term.

I've tried numerous ways to get these to render the way I would like to no avail. I've tried:

taxonomy_term_load_multiple($node->field_categories);

along with a combination of other iterative statements which weren't successful. Ideally, I would like for each taxonomy term for that node to render along the following lines:

<div class="[field_icon_class]">[taxonomy term name]</div>

Any ideas how this can be accomplished, or any module exists to do so? Much thanks!

1 Answer 1

1

Are you cool with using views? I do this type of thing all the time on my site. If you are then reply back and I'll post an example.

3
  • Hey! I never thought of using Views! Brilliant, thanks Rob. I've wired up a view of Taxonomy Terms, added a relationship to my content type field using that vocab, added a contextual filter of Content: Nid, and finally added an EVA Field display type (provided by the Entity Views Attach module). Works like a charm!
    – maGz
    Commented Feb 25, 2014 at 11:11
  • I've outlined my solution in the comment above, so this is solved, but seeing that you helped me realise an option that I did not even think of, I've marked your post as the answer.
    – maGz
    Commented Feb 25, 2014 at 11:14
  • Superb! I'm glad it worked for you. There's always oodles of ways to pull of different things in drupal, eh?
    – Rob
    Commented Feb 25, 2014 at 19:52

Your Answer

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

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