The breadcrumb can be overwrite by the breadcrumb created by the hierarcical terms of taxonomy. Maybe everybody find it's normal, but in my case, I don't like that !

example : it term1 is parent of term2 and I want an item in the menu like "term2" (pointing /taxonomy/term/2). The breadcrumb display is Home >> term1. I don't use hierarchical term but I want to use taxonomy term in my submenus.

So I found that : in the module taxonomy, in the taxonomy.pages.inc, the function taxonomy_term_page calls the function drupal_set_breadcrumb but after the module menu_breadcrumb. This call create another breadcrumb and it's not based on the menu. So I tried to add a condition in taxonomy_term_page and it works. But I'm not sure that it's good to modify a function of the drupal core.... I show you what I do :

The original code was :

         $breadcrumb = array();
          while ($parents = taxonomy_get_parents($current->tid)) {
            $current = array_shift($parents);
            $breadcrumb[] = l($current->name, 'taxonomy/term/'. $current->tid);
          }
          $breadcrumb[] = l(t('Home'), NULL);
          $breadcrumb = array_reverse($breadcrumb);
          drupal_set_breadcrumb($breadcrumb);

and I've just added a condition :

$breadcrumb = drupal_get_breadcrumb();
if (empty($breadcrumb)) {
          .....same here....
}

I don't use term hierarchy and I don't see problems in my website with that.
I don't know what is possible to do in the menu_breadcrumb but I want to inform you for my discover ;)

Comments

yacks’s picture

Assigned: yacks » Unassigned
xurizaemon’s picture

Status: Active » Fixed

You may be able to resolve that by setting the weight of Menu Breadcrumb to a higher value than Taxonomy, so that MB's breadcrumb will be set after Taxo's.

You can adjust this directly via SQL, or install a module for the purpose, if you like that sort of thing.

Pls see http://drupal.org/node/110238 for details.

Does that solve your problem?

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

vipaware’s picture

I have similar problem, but in addition I'm using i18ntaxonomy.
Changing weights of menu_breadcrumb doesn't help. It only helps if I comment drupal_set_breadcrumb() call in i18ntaxonomy.pages.inc to prevent overwriting the breadcrumb by i18ntaxonomy (similar solution to yacks').
I'm using php function debug_backtrace() to see when drupal_set_breadcrumb() is called and by what function. It's clearly seen that i18ntaxonomy module is called last, without regard menu_breadcrumb module weight.
If you know the other working corehackless solution, let me know.

vipaware’s picture

Status: Closed (fixed) » Active

2xurizaemon
Sorry, for putting this into active again, but your solution doesn't work, at least for me. Please, read my previous message for more info.
Feel free to close this issue however, I just might use corehack solution then, I've already spent too much time sorting this out.

xurizaemon’s picture

Status: Active » Fixed

Menu Breadcrumb sets the breadcrumb in hook_init().

Internationalization Taxonomy sets the breadcrumb in hook_nodeapi().

(Taxonomy module only sets breadcrumb on the taxonomy_term_page() callback - so my suggested solution for yacks above probably would never have worked.)

_nodeapi() is always going to get run after _init(), so in order to override the behaviour of i18ntaxonomy, you're going to need to add a custom module which sets the breadcrumb according to Menu Breadcrumb's configuration / methodology *after* the i18ntaxonomy has had its way with it.

it looks like i18ntaxo only bothers forum pages anyway? that seems wierd

I haven't tested this, just had a quick read. Hope that helps you enough to get you sorted.

Sborsody’s picture

This seems to be an issue with both taxonomy and book pages (I suppose, for any module that sets breadcrumbs). Just for fun, I tried calling menu_breadcrumb_init() from inside MYTHEME_taxonomy_term_page() to see if the breadcrumb would get set to the menu. Doesn't work.

vipaware’s picture

Are you sure MYTHEME_taxonomy_term_page() function is called at all in your case?

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Sborsody’s picture

Yes. MYTHEME_taxonomy_term_page() gets called.

I've been gone for two weeks away from this problem, away from Drupal. I may open a new issue as I warm back up.

Sborsody’s picture

The problem stems from the mishmash of places where everyone's modules do a drupal_set_breadcrumb (which ultimately comes from just the weakness of Drupal's handling of breadcrumbs). Taxonomy doesn't care if there's a breadcrumb already set and it has no option for optionally setting the breadcrumb. I noticed that menu_get_active_breadcrumb() returns the breadcrumb set by MB so I just change whatever the breadcrumb got set to by other modules to that when the breadcrumb gets themed.

In template.php of my theme I put:

function MYTHEME_breadcrumb($breadcrumb) {
  if (!empty($breadcrumb)) {
    $breadcrumb = menu_get_active_breadcrumb();
    return '<div class="breadcrumb">'. implode(' » ', $breadcrumb) .'</div>';
  }
}

I realize this is part of the larger discussion regarding how Drupal does breadcrumbs. My opinion is that individual modules (taxonomy, blog, book, forum, etc.) probably shouldn't be doing the actual setting of breadcrumbs but only return a breadcrumb when asked. Then let the theme designer handle choosing breadcrumbs at the theme level. Or in other words, theme_breadcrumb() is your last chance to modify the breadcrumb before it is rendered!

GaëlG’s picture

This problem is being addressed for D8 core: #1495510: TermBreadcrumbBuilder::build() overrides any possible breadcrumb It might be backported then.

anou’s picture

Thanks Sborsody ! This fixes the taxonomy breadcrumb "problem" I had.

deminy’s picture

Sborsody's solution (#11) does work. I made minor changes based on his code so that the function respects settings in module Menu Breadcrumb. This function has been tested and verified on my site (Drupal 7, not Drupal 6).

Add following function to file template.php of the theme you use:

function MYTHEME_breadcrumb($breadcrumb) {
  if (!empty($breadcrumb)) {
    $breadcrumb = menu_get_active_breadcrumb();
  	if (count($breadcrumb) > 1 || !variable_get('menu_breadcrumb_hide_on_single_item', 0)) {
  		return '<div class="breadcrumb">' . implode(' » ', $breadcrumb) . '</div>';
    }
  }
}
2pha’s picture

I needed the page title too so amended deminy's code.

function MYTHEME_breadcrumb($breadcrumb) {
  if (!empty($breadcrumb)) {
    $breadcrumb = menu_get_active_breadcrumb();
    if (count($breadcrumb) > 1 || !variable_get('menu_breadcrumb_hide_on_single_item', 0)) {
      if(variable_get('menu_breadcrumb_append_node_title', 0)){
        $breadcrumb[] = drupal_get_title();
      }
      return '<div class="breadcrumb">' . implode(' » ', $breadcrumb) . '</div>';
    }
  }
}
granticusiv’s picture

#15 worked for me, thanks