function _taxonomy_breadcrumb_generate_breadcrumb in Taxonomy Breadcrumb 6
Same name and namespace in other branches
- 7 taxonomy_breadcrumb.inc \_taxonomy_breadcrumb_generate_breadcrumb()
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.inc - Set a Taxonomy breadcrumb and call the original taxonomy/term/% callback.
File
- ./
taxonomy_breadcrumb.inc, line 122 - helper functions for taxonomy_breadcrumb
Code
function _taxonomy_breadcrumb_generate_breadcrumb($tid, $is_term_page = FALSE) {
$term = taxonomy_get_term($tid);
// Generate the HOME breadcrumb.
$home_text = variable_get('taxonomy_breadcrumb_home', t('Home'));
if ($home_text != '') {
$breadcrumb[] = l($home_text, NULL);
}
// Generate the VOCABULARY breadcrumb.
$vocabulary_path = _taxonomy_breadcrumb_get_vocabulary_path($term->vid);
if ($vocabulary_path != NULL) {
$vocabulary = taxonomy_vocabulary_load($term->vid);
$breadcrumb[] = l(_taxonomy_breadcrumb_tt("taxonomy:vocabulary:{$term->tid}:name", $vocabulary->name), $vocabulary_path);
}
// Generate the TERM breadcrumb.
$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));
}
if ($term_path == '<none>') {
continue;
}
$term_title = $parent_term->name;
// Use the SYNONYM instead of TERM, if we want to.
if (variable_get('taxonomy_breadcrumb_use_synonym', FALSE)) {
$synonyms = taxonomy_get_synonyms($parent_term->tid);
if (!empty($synonyms)) {
$term_title = $synonyms[0];
}
}
// 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(_taxonomy_breadcrumb_tt("taxonomy:term:{$parent_term->tid}:name", $term_title));
}
else {
$breadcrumb[] = l(_taxonomy_breadcrumb_tt("taxonomy:term:{$parent_term->tid}:name", $term_title), $term_path);
}
}
// Optionally remove the current TERM from end of breadcrumb trail.
if (!variable_get('taxonomy_breadcrumb_show_current_term', TRUE) && !is_null($breadcrumb)) {
array_pop($breadcrumb);
}
return $breadcrumb;
}