Bug with breadcrumbs containing sibling menu items as parents

mdixoncm - October 30, 2009 - 10:07
Project:Menu Trails
Version:6.x-1.0
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:needs review
Description

Quite a subtle one this. If you have a heirarchical menu structure in which 2 (or more) siblings have children, such as this

- Item 1
-- Child 1
-- Child 2
-- Child 3
- Item 2
-- Child 4
-- Child 5

And you use the menu trails module setting Child5 as the target then the breadcrumb generated will be

Item1 > Item2 > Child 5

NOTE the sibling (item1) appearing whear it shouldn't

I've tracked this down to the _menutrails_recurse_crumbs function, where an array of "above" items is being generated and passed into the recursive function. For each of the top level items, $above is just being added to each time so when you get to the second item $above already contains the first item (if that makes any sense).

Simple solution is to not touch the $above variable - so you end up with something like

    if (is_array($menu_item['below'])) {
  $new_above = $above;  //Don't go changing the $above variable as we need this for the next pass
  $new_above[] = $menu_item;
      _menutrails_recurse_crumbs($menu_item['below'], $item, $crumbs, $new_above);
    }

I'll pop this into a patch in a mo ...

#1

jmbarlow - November 3, 2009 - 22:09
Status:active» reviewed & tested by the community

Well spotted. This proposed patch sorts out the problem for me.

(Nice module btw. "Does what is says on the tin")

#2

sun - November 3, 2009 - 23:49
Status:reviewed & tested by the community» active

There is no patch here.

#3

rho_ - November 20, 2009 - 18:29
Status:active» needs review

Worked great for me, rolled a patch from the menutrails directory. Good catch mdixoncm!

AttachmentSize
menutrai_above.patch 577 bytes
 
 

Drupal is a registered trademark of Dries Buytaert.