You are here

function taxonomy_menu_vocabulary_path_path_vocab_view in Taxonomy menu 6.2

Callback for hook_taxonomy_menu_path

File

taxonomy_menu_vocabulary_path/taxonomy_menu_vocabulary_path.module, line 55
Adds a tad extra functionality to the new Taxonomy Menu.

Code

function taxonomy_menu_vocabulary_path_path_vocab_view($vid, $tid) {
  $vocab_path = variable_get('taxonomy_menu_taxonomy_menu_vocabulary_path_' . $vid, 'category');

  //if tid = 0 then we are creating the vocab menu item format will be /vocabname
  if ($tid == 0) {
    $path = $vocab_path;
  }
  else {
    if (variable_get('taxonomy_menu_vocabulary_path_use_custom_path_for_term_menu_path_' . $vid, FALSE)) {
      $path = $vocab_path . '/' . taxonomy_get_term($tid)->name;
    }
    else {
      $path = taxonomy_term_path(taxonomy_get_term($tid));
    }
    if (variable_get('taxonomy_menu_display_descendants_' . $vid, FALSE)) {

      //we wait to run this instead of durning the if above

      //because we only wan to run it once.
      $terms = taxonomy_get_tree($vid, $tid);
      foreach ($terms as $term) {
        $tids[] = $term->tid;
      }
      if ($tids) {
        $end = implode(' ', $tids);
        $path .= ' ' . $end;
      }
    }
  }
  return $path;
}