Breadcrumb only shows "Home" on all pages, 2 & 3 levels deep.

Comments

nancydru’s picture

Confirmed. Here's what I'm doing:

function nancy_preprocess_page(&$variables, $hook) {
  // Get breadcrumbs from menu.
  $items = menu_tree_page_data('menu-main');

  // The first element is the home page for the site.
  $item = current($items);
  $bc = array(l(t($item['link']['title']), $item['link']['href'], $item['link']['options']));

  // Find the highest level active item.
  _nancy_spin_menu($items, $bc);

  if ($bc) {
    $variables['breadcrumb'] = theme('breadcrumb', $bc);
  }
}

/**
 * Recursive helper function for running the menu tree for breadcrumbs.
 */
function _nancy_spin_menu($items, &$bc) {
  // Find the highest level active item.
  $oops = TRUE;
  foreach ($items as $key => $item) {
    if ($item['link']['in_active_trail']) {
      $oops = FALSE;
      break;
    }
  }

  // If nothing was located, just go back.
  if ($oops) {
    return NULL;
  }

  // Let's add this one to the breadcrumbs, except front page,
  // as we always do that first.
  if ($item['link']['href'] != '<front>') {
    $bc[] = l(t($item['link']['title']), $item['link']['href'], $item['link']['options']);
  }

  // Is there a lower level?
  if ($item['below']) {
    // Find the next highest level active item.
    _nancy_spin_menu($item['below'], $bc);
  }

  return $bc;
}

This gives me breadcrumbs for everything that is a menu item (so make sure your Views are in the menu).

shruti.sheth’s picture

Hi,
I added the above given functions to my template.php but with nice menus it is not giving the required breadcrumbs for for the nodes two three level deep.

Thanks,
Shruti.

nancydru’s picture

I threw Nice Menus out in favor of PR's Superfish menus. I have the code in my site-specific module, so I don't know if it would work the same in the theme file (I really try not to touch theme code because it will get lost if I go to a new version).

grifon’s picture

I found it happens for me when Node Hierarchy module is enabled. Comes right back when you disable it.

nancydru’s picture

I have never heard of Node hierarchy, so obviously I didn't have it installed.

Jeff Burnz’s picture

Status: Active » Postponed (maintainer needs more info)

Is this actually a theme bug or something Nice menu/Drupal related, I get all the breadcrumbs on pages such as forum nodes etc, so I don't really understand this bug report.

nancydru’s picture

Since I had to switch to a different theme because of #1117154: Wierd theme problem, I can't answer you. I think it was a menu issue (core), but I'm not sure. I believe the Menu Block module would fix it.

Jeff Burnz’s picture

Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)

Not a theme issue.

richH’s picture

Hi, I've got a straight pixture_reloaded D6 installation and I have exactly this effect.

On the nodes which I have created I only ever get "home" displayed.

On other nodes (e.g. Forum) I get the full breadcrumb.

See the pics:

- Leihneos ist an Article page and has no breadcrumb (should be Startseite --> Leihneos)

- Lauftraining is a Forum topic and has a breadcrumb.

Stumped as to what this problem is.

Thanks
RIch

Jeff Burnz’s picture

This is how Drupal 6 works, sorry but this has nothing to do with the theme - its just how things work - you need to build breadcrumbs in Drupal - for example Book and Forum modules build their own breadcrumbs, there are quite a few contrib modules to help you with this.

operations’s picture

Perfect solution for a client's SuperFish rediculous big menu :) I had a deep menu tree and the breadcrumbs on my drupal instance were only showing Home and sometimes showing incorrect trail.

I used the above code and it worked perfectly.. Many thanks @NancyDru.