Take the 2-minute tour ×
Drupal Answers is a question and answer site for Drupal developers and administrators. It's 100% free, no registration required.

In Drupal 7, you can use taxonomy-term.tpl.php to override taxonomy pages.

Inside the taxonomy-term.tpl.php page, you can use <?php print $term->field_NAME['und'][0]['value'];?>to print out the content of any fields attached to the taxonomy term. (*)

However, how do you get to the list of nodes that is displayed on the taxonomy page?

There doesn't seem to be anything in the taxonomy-term.tpl.php file to indicate how to theme the nodes that are displayed on the term page.

I know you can use Views to over ride the page. However, Views does not let you display nodes tagged with a term and fields that are attached to the term in a single View.

(*) I know you are not supposed to use UND. However, the correct method for access node based fields does not seem to work with taxonomy based fields.

share|improve this question
add comment

1 Answer 1

up vote 2 down vote accepted

The template file you want to use is not taxonomy-term.tpl.php; that's used for the taxonomy header at the top of the page. The template file used is node.tpl.php.

If you look at taxonomy_term_page() which is used to build the term page view, you will see the nodes are build separately by calling node_view_multiple(). node_view_multiple() is just a wrapper for node_view(), which uses the standard node.tpl.php file.

Also you should be able to use field_get_items() for taxonomy terms. I'll look for something like $field = field_get_items('taxonomy_term', $term, 'field_name');.

I haven't tried but it should work.

You should really never use 'und', but the constant LANGUAGE_NONE.

share|improve this answer
1  
Thank you for your kindness in replying! If I use a custom node.tpl.php file it affects all nodes and not just those displayed on mysite.com/taxonomy/term/[tid]. Is there a way to specify a template just to hide the nodes on the taxonomy index page? I know I can hide all the fields for teaser display on the manage display tab of the admin interface, but I would like to do it at theme layer. Also the $field code you posted on prints out the words "Array". How do I make it display the value in the array? –  big_smile Jun 15 '11 at 6:50
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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