Return to Snippet

Revision: 10243
at December 13, 2008 21:04 by robotoverlord


Initial Code
In template.php

<?php
function mythemename_taxonomy_links($node, $vid) {

//if the current node has taxonomy terms, get them
  if (count($node->taxonomy)):

    $tags = array();
     foreach ($node->taxonomy as $term) {
       if ($term->vid == $vid):
          $tags[] = l($term->name, taxonomy_term_path($term));
          endif;
}
    if ($tags):
//get the vocabulary name and name it $name
        $vocab = taxonomy_get_vocabulary($vid);
        $name = $vocab->name;
        $output .= t("$name") . ": " . implode(' | ', $tags);
    endif;

  endif;

     if ($output):
       return $output;
     endif;

}
?>

In page.tpl.php

<?php
$nid = arg(1);
print yourthemename_print_terms($nid);
?>

Initial URL

                                

Initial Description

                                

Initial Title
Drupal print Vocabularies and Terms associated with a node

Initial Tags
drupal

Initial Language
PHP