--- taxonomy_context.module.original 2004-10-26 04:03:04.000000000 +1000 +++ taxonomy_context.module 2005-02-12 17:39:26.000000000 +1100 @@ -3,14 +3,19 @@ /** * Implementation of hook_init - * Set breadcrumb, and show some infos about terms, subterms + * Set breadcrumb, and show some infos about terms, subterms + * Patched to make breadcrumbs on nodes work, by using taxonomy_context_get_context() call + * Patch done by x on xxxx-xx-xx */ function taxonomy_context_init() { $mode = arg(0); - $paged = !empty($_GET["from"]); - - if (variable_get("taxonomy_context_use_style", 1)) { + $paged = !empty($_GET["from"]); + + // Another little patch to make the CSS link only get inserted once + static $taxonomy_context_css_inserted = FALSE; + if (variable_get("taxonomy_context_use_style", 1) && !$taxonomy_context_css_inserted) { drupal_set_html_head(''); + $taxonomy_context_css_inserted = TRUE; } if (($mode == "node") && (arg(1)>0)) { @@ -18,9 +23,20 @@ $node_type = $node->type; } // Commented out in response to issue http://drupal.org/node/11407 -// if (($mode == "taxonomy") || ($node_type == "story") || ($node_type == "page")) { -// drupal_set_breadcrumb(taxonomy_context_get_breadcrumb($context->tid)); -// } + // Un-commented for breadcrumb patch + // NOTE: you don't have to have all the node types below - only story and page are essential + $context = taxonomy_context_get_context(); + $context_types = array( + "story", + "page", + "image", + "weblink", + "webform", + "poll" + ); + if ( ($mode == "taxonomy") || (is_numeric(array_search($node_type, $context_types))) ) { + drupal_set_breadcrumb(taxonomy_context_get_breadcrumb($context->tid, $mode)); + } } /** @@ -93,9 +109,13 @@ } /** - * Return the breadcrumb of taxonomy terms ending with $tid + * Return the breadcrumb of taxonomy terms ending with $tid + * Patched to display the current term only for nodes, not for terms + * Patch done by x on xxxx-xx-xx + * Patched to call taxonomy_get_parents_all() with the optional $distantparent argument set to TRUE, to implement cross-vocabulary hierarches. + * Patch done by x on xxxx-xx-xx */ -function taxonomy_context_get_breadcrumb($tid) { +function taxonomy_context_get_breadcrumb($tid, $mode) { $breadcrumb[] = l(t("Home"), ""); if (module_exist("vocabulary_list")) { @@ -104,12 +124,15 @@ $breadcrumb[] = l($vocab->name, "taxonomy/page/vocab/$vid"); } - if ($tid) { - $parents = taxonomy_get_parents_all($tid); + if ($tid) { + // New $distantparent argument added with value TRUE + $parents = taxonomy_get_parents_all($tid, TRUE); if ($parents) { $parents = array_reverse($parents); - foreach ($parents as $p) { - $breadcrumb[] = l($p->name, "taxonomy/term/$p->tid"); + foreach ($parents as $p) { + // The line below implements the breadcrumb patch + if ($mode != "taxonomy" || $p->tid != $tid) + $breadcrumb[] = l($p->name, "taxonomy/term/$p->tid"); } } }