Is there any way to display the taxonomy terms slightly differently depending on the content type they appear in? For instance, I have two content types that I'd like to have use the same vocabulary, but the terms represent slightly different things to end users.

Example: a node field asks an organization "how are you interested in connecting with a campus?" and answers include "lead an interactive workshop" and "participate on a panel". When a different content type asks a teacher "how are you interested in organizations connecting with you?" the answers include "have an organization lead a workshop" and "host a panel". Obviously those answers correspond 1:1, so I'd like to use the same vocabulary. But they need to present themselves slightly differently in each content type.

1 Answer 1


Since vocabularies are linked to nodes via fields you'd be best off handling this in hook_preprocess_node() in your theme file:

function MYTHEME_preprocess_node(&$vars) {
  $node = $vars['node'];

  // Only make the change if this is a certain node type
  if ($node->type == 'my_type') {
    // Extract the term IDs from the field
    $tids = array();
    foreach ($node->field_vocab[$node->language] as $value) { 
      $tids[] = $value['tid'];

    // This example adds the taxonomy terms to a simple list, you'll
    // want to replace this with whatever theme function you need
    $items = array();
    foreach (taxonomy_term_load_multiple($tids) as $term) {
      $items[] = l($term->name, "taxonomy/term/$term->tid");

    // Replace field_vocab in the vars with the new content
    $vars['field_vocab'] = theme('item_list', array('items' => $items));

That might need to be changed/added to depending on your needs but it should give you a place to start from. Once you've added the new hook to the template.php file make sure you clear Drupal's hooks so the registry will be updated.

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.