Posted By

robotoverlord on 12/13/08


Tagged

drupal taxonomy vocabulary


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

basicmagic
panatlantica


Drupal print Vocabularies and Terms associated with a node


 / Published in: PHP
 

  1. In template.php
  2.  
  3. <?php
  4. function mythemename_taxonomy_links($node, $vid) {
  5.  
  6. //if the current node has taxonomy terms, get them
  7. if (count($node->taxonomy)):
  8.  
  9. $tags = array();
  10. foreach ($node->taxonomy as $term) {
  11. if ($term->vid == $vid):
  12. $tags[] = l($term->name, taxonomy_term_path($term));
  13. endif;
  14. }
  15. if ($tags):
  16. //get the vocabulary name and name it $name
  17. $vocab = taxonomy_get_vocabulary($vid);
  18. $name = $vocab->name;
  19. $output .= t("$name") . ": " . implode(' | ', $tags);
  20. endif;
  21.  
  22. endif;
  23.  
  24. if ($output):
  25. return $output;
  26. endif;
  27.  
  28. }
  29. ?>
  30.  
  31. In page.tpl.php
  32.  
  33. <?php
  34. $nid = arg(1);
  35. print yourthemename_print_terms($nid);
  36. ?>

Report this snippet  

You need to login to post a comment.