You are here

function taxonomy_menu_path_default in Taxonomy menu 7

Same name and namespace in other branches
  1. 8 taxonomy_menu.module \taxonomy_menu_path_default()
  2. 6.3 taxonomy_menu.module \taxonomy_menu_path_default()
  3. 6.2 taxonomy_menu.module \taxonomy_menu_path_default()
  4. 7.2 taxonomy_menu.module \taxonomy_menu_path_default()

Callback for hook_taxonomy_menu_path.

1 string reference to 'taxonomy_menu_path_default'
taxonomy_menu_create_path in ./taxonomy_menu.module
Creates the path for the vid/tid combination.

File

./taxonomy_menu.module, line 808
Adds links to taxonomy terms into a menu.

Code

function taxonomy_menu_path_default($vid, $tid) {

  // If tid = 0 then we are creating the vocab menu item format will be taxonomy/term/$tid+$tid+$tid...
  if ($tid == 0) {

    // Get all of the terms for the vocab.
    $vtids = _taxonomy_menu_get_terms($vid);
    $end = implode('/', $vtids);
    $path = "taxonomy/term/{$end}";
  }
  else {
    $path = 'taxonomy/term/' . $tid;
    if (variable_get(_taxonomy_menu_build_variable('display_descendants', $vid), FALSE)) {

      // Use 'all' at the end of the path.
      if (variable_get(_taxonomy_menu_build_variable('end_all', $vid), FALSE)) {
        $path .= '/all';
      }
      else {

        // We wait to run this instead of during the if above because we only
        // want to run it once.
        $terms = taxonomy_get_tree($vid, $tid);
        foreach ($terms as $term) {
          $tids[] = $term->tid;
        }
        if (isset($tids)) {
          $end = implode('/', $tids);
          $path .= '/ ' . $end;
        }
      }
    }
  }
  return $path;
}