I have a taxonomy field attached to a content type. On the teaser view mode, the field is hidden. I have two sections where I display the content type's teasers. On one section I don't want the terms to show. On the other section, I want them displayed.

I would like to know how I can render this field from the template node.tpl.php. It's not available as an element of $content, but is attached to the $node object.


1 Answer 1


You can add any markup or additional fields to the node teaser view or node full view using hook_node_view(). The following example is adding a taxonomy name to the teaser view.

function MYMODULE_node_view($node, $view_mode = 'full', $langcode = NULL) {
    if($view_mode == 'teaser'){
     $tname = db_query('SELECT name FROM {taxonomy_term_data} t WHERE tid = :tid', array(':tid'=>$node->field_category['und'][0]['tid']))->fetchField();     
     $node->content['my_taxonomy'] = array(     
        '#markup' => '<div>'.$tname.'</div>', 
        '#weight' => 10, 

You would not need to update node.tpl.php.

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.