0

Currently I want to theme a taxonomy field in my content type and expose the TID and the Term name with link. The default sections only give me one or the other. Is there a setup where I can expose the TID, Term name, and Link?

Below is a screenshot of the teaser view display mode.

enter image description here

2 Answers 2

1

You could use field.tpl.php

If your field is called field_series then you will need to create:

/mytheme/anyfolder(optional)/field--field-series.tpl.php

If you inspect the variable $element then it will contain everything you'll need (tid, name, see drupal_get_path_alias for the link)

Don't forget to clear the cache once the new template has been created.

1

Felix is right on. If you want a UI for this for some help and flexability look at Fences.

What it's doing

Behind the scenes, the Fences module is remembering which custom tpl file you want to use for each field. This is set in the field configuration itself — not in the display (or view mode) configuration. That way, every time to output this field, it will use this custom tpl.

Fences ships with a bunch of tpls files. Look inside the module to see which ones, and to see the markup for each of those. If you would like to change that markup, make a copy of any tpl file, put it in your custom theme, and edit away. Drupal will automatically use the copy in your theme instead of the copy in the Fences module files (once you clear the cache).

If you would like to make more things — and add to the list of possibilities — make more tpls files of your own, and place them in your theme. Use the fences naming convention, and Fences will automatically find them, and add them to the list available in the dropdown for field configuration.

Or jump in and try out DisplaySuite which allows you to customize fields, or whole Node displays ...

Display Suite allows you to take full control over how your content is displayed using a drag and drop interface. Arrange your nodes, views, comments, user data etc. the way you want without having to work your way through dozens of template files. A predefined list of layouts (D7 only) is available for even more drag and drop fun!

By defining custom view modes (build modes in D6), you can define how one piece of content should be displayed in different places such as teaser lists, search results, the full node, views etc.

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.