You are here

function taxonomy_breadcrumb_generate_breadcrumb in Taxonomy Breadcrumb 5

If the current drupal path (q=) is /node/nid, generate the breadcrumb trail based on nid.

2 calls to taxonomy_breadcrumb_generate_breadcrumb()
taxonomy_breadcrumb_nodeapi in ./taxonomy_breadcrumb.module
Implementation of hook_nodeapi().
taxonomy_breadcrumb_term_page in ./taxonomy_breadcrumb.module
This function overrides the core taxonomy_term_page. First, call the core taxonomy_term_page. Then, alter the breadcrumb trail. This module's hook_menu and a module weight greater than taxonomy's ensure this function gets called for the…

File

./taxonomy_breadcrumb.module, line 84
The taxonomy_breadcrumb module generates taxonomy based breadcrumbs on node pages and taxonomy/term pages. The breadcrumb trail takes on the form: [HOME] >> [VOCABULARY] >> TERM >> [TERM] ...

Code

function taxonomy_breadcrumb_generate_breadcrumb($tid, $is_term_page = FALSE) {
  $term = taxonomy_get_term($tid);

  // HOME breadcrumb generation
  $home_text = variable_get('taxonomy_breadcrumb_home', '');
  if ($home_text != '') {
    $breadcrumb[] = l($home_text, NULL);
  }

  // VOCABULARY breadcrumb generation
  $vocabulary_path = taxonomy_breadcrumb_get_vocabulary_path($term->vid);
  if ($vocabulary_path != NULL) {
    $vocabulary = taxonomy_get_vocabulary($term->vid);
    $breadcrumb[] = l($vocabulary->name, $vocabulary_path);
  }

  // TERM breadcrumb generation
  $parent_terms = array_reverse(taxonomy_get_parents_all($tid));
  foreach ($parent_terms as $parent_term) {
    $term_path = taxonomy_breadcrumb_get_term_path($parent_term->tid);
    if ($term_path == NULL) {
      $term_path = taxonomy_term_path(taxonomy_get_term($parent_term->tid));
    }

    // Do not create links to own self if we are on a taxonomy/term page.
    if ($is_term_page && $parent_term->tid == $tid) {
      $breadcrumb[] = check_plain($parent_term->name);
    }
    else {
      $breadcrumb[] = l($parent_term->name, $term_path);
    }
  }

  // Remove current TERM from end of breadcrumb trail
  if (!variable_get('taxonomy_breadcrumb_show_current_term', TRUE) && !is_null($breadcrumb)) {
    array_pop($breadcrumb);
  }
  return $breadcrumb;
}