When the active-trail is added in menu_navigation_links() any previously added attributes are lost.
On line 1317 of the current HEAD (rev 1.275) it looks like this:
if ($item['link']['in_active_trail']) {
$l['attributes'] = array('class' => 'active-trail');
}
As you can see the $l['attributes'] is just assigned without checking if it is already defined or not.
A possible fix is to change it to look like this:
if ($item['link']['in_active_trail']) {
// only initiate $l['attributes'] to an empty array if it doesn't already exist
if (!isset($l['attributes'])) $l['attributes'] = array();
// if $l['attributes']['class'] exists append ' active-trail'
// and if it doesn't just assign 'active-trail'
if (isset($l['attributes']['class'])) {
$l['attributes']['class'] .= ' active-trail';
}
else {
$l['attributes']['class'] = 'active-trail';
}
}
Comments
Comment #1
Anonymous (not verified) commentedComment #2
pwolanin commentedno actual patch attached. see: http://drupal.org/patch
Comment #3
pwolanin commentedFYI - that code was added in this recent issue: http://drupal.org/node/249571
So, I think we may be able to fix before 6.3 even. However, it should be fixed in 7.x first.
Maybe it could be coded more compactly:
Comment #4
Anonymous (not verified) commentedI just checked out drupal from cvs but I can't see those changes in there.
this is what I checked out:
cvs -d:pserver:anonymous:anonymous@cvs.drupal.org:/cvs/drupal checkout drupal
Did I checkout the wrong version?
Comment #5
pwolanin commentedthat checkout should give you HEAD (7.x). Which changes were you looking for?
The above code is a little wrong. Should be more like:
Comment #6
Anonymous (not verified) commentedI was looking for the changes mentioned here http://drupal.org/node/249571
According to the comments in the thread it looks like it was commited both to the 6 and 7 branches.
Comment #7
pwolanin commentedThe code is there in 7.x. line 1318 of menu.inc: $l['attributes'] = array('class' => 'active-trail');
Here's a patch for 7.x, also applies to 6.x with fuzz.
Comment #8
pwolanin commentedComment #9
chx commentedNice and simple.
Comment #10
pwolanin commentedhere's a patch that applies with no fuzz to 6.x (exact same code).
Comment #11
pwolanin commentedpatch still applies cleanly to 7.x
All tests pass with the patch, except for known failures (same with and without the patch):
Site-wide contact form: 120 passes, 4 fails, 0 exceptions
Core filters: 48 passes, 12 fails, 0 exceptions
Poll create: 27 passes, 7 fails, 0 exceptions
XML-RPC validator 0 passes, 0 fails, 3 exceptions
Comment #12
paul.lovvik commented#10 patch applies cleanly to 6.3. Code looks good.
Comment #13
gábor hojtsyOK, committed to 6.x and keeping RTBC for 7.x.
Comment #14
dries commentedCommitted to CVS HEAD for D7.x. Thanks.
Comment #15
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.