I am trying to modify my theme to display the whole path for taxonomy terms in nodes, for example:
My vocabulary are organized this way:
Computer
--Linux
----Hardware

When I choose Hardware only Hardware are displayed as term for that node, I want the whole path Computer/Linux/Hardware to be displayed.

How can I make this happend?

//Nimo

Comments

mirko’s picture

you can give a try to taxonomy breadcrumb

Nimo’s picture

Thanks for the tip, unfortunately this is not exactly what I was looking for.

That module are able to change the breadcrumb, but what I am looking for are some way to list the whole path for each of all nodes in any node listing.

Something like: "Submitted by nimo in vocabulary/term/term".

Nimo’s picture

With the following code in template.php I come close to what I want, the only problem with this code is that the terms comes in reverse order, ie: Hardware/Linux/Computer instead for Computer/Linux/Hardware.

How can I get them in the right order instead?

function _phptemplate_variables($hook, $vars) {
  $variables = array();
  if ($hook == 'node') {
   if (module_exists('taxonomy')) {
     foreach (taxonomy_get_vocabularies($vars['node']->type) as $vid=>$vocab) {
       foreach (taxonomy_node_get_terms_by_vocabulary($vars['node']->nid, $vid) as $term) {
         if ($vocab->tags) {
           $tag_links[] = l($term->name, taxonomy_term_path($term), array('rel' => 'tag', 'title' => $term->description));
         }
         else {
           $parents = taxonomy_get_parents_all($term->tid);
           $test = "";
           foreach($parents as $parent) {
             $test .= $parent->name;
             $test .= "/";
           }
           $term_links[] = $test ."/". l($term->name, taxonomy_term_path($term), array('rel' => 'tag', 'title' => $term->description));
         }
       }
     }
   }
   else {
     $term_links = array();
     $tag_links = array();
   }

   //$variables['terms'] = theme_links('links', $term_links);
   //$variables['tags'] = theme_links('links', $tag_links);
   $variables['terms'] = phptemplate_nclinks($term_links);
   $variables['tags'] = phptemplate_nlinks($tag_links);
  }
}