You are here

function taxonomy_menu_hierarchy_path_hierarchy in Taxonomy menu 6.2

Callback for hook_taxonomy_menu_path

File

taxonomy_menu_hierarchy/taxonomy_menu_hierarchy.module, line 22
Enables Hierarchy path to Taxonomy Menu

Code

function taxonomy_menu_hierarchy_path_hierarchy($vid, $tid) {

  //setup the base path of category/vid
  $path = variable_get('taxonomy_menu_hierarchy_base_' . $vid, 'category') . '/' . $vid;

  //if tid = 0 then we are getting the vocab item path
  if ($tid == 0) {
    return $path;
  }

  //get the parents of the term
  $parents = taxonomy_get_parents_all($tid);

  //cycle through the parents and add them as an item on the menu
  if (!empty($parents)) {
    $path_tids = '';
    foreach ($parents as $parent) {
      $path_tids = '/' . $parent->tid . $path_tids;
    }
    $path .= $path_tids;
  }
  return $path;
}