Parent menu loses "active" style when loading child menu items

seaneffel - June 24, 2008 - 23:57
Project:Drupal
Version:5.7
Component:menu system
Category:bug report
Priority:normal
Assigned:Unassigned
Status:active
Description

This definitely has been discussed before, and fixed in D6, but can that same solution be applied to the D5 menu system?

Regarding the D6 fix:
http://drupal.org/node/77485

What do you think?

#1

hansBKK@drupal.org - July 21, 2008 - 09:02

+1 PLEASE!

This has been driving me nuts. I've got the same menu listed for both Primary and Secondary, and so far all the methods I've found and tried work OK for primary but not for secondary (work = get class "active" assigned)

Ideally I'd like the path alias to trigger the assignment of the class independently of how the user got there, and the link could be anywhere on the page, not just primary/secondary or even not in the menuing system?

e.g. a page display aliased to /about/facilities/sports would have any menu items anywhere on the page pointing to /about and /about/facilities would get the active class. Seems like something an add-on module similar to menu trails could do

Four Seasons page template uses this:

    foreach($primary_links as $key => $value ) {
      if (ereg('active', $key)) {
        $primary_links[$key]['attributes']['class'] = "active";
      }
    }

which looks like it could be generalized, but when I tried to apply it to secondary_links I got error messages on the second and subsequent page loads - but not the first??

A systemic solution would be great, but in the meantime I'll keep trying the various options scattered around drupal.org. Otherwise I'll have to hand-code my secondary nav for each section of my site .

Pointers to perhaps obscure but known-reliable solutions would be most welcome.

#2

magico - July 21, 2008 - 19:49

(subscribe)

#3

hansBKK@drupal.org - July 22, 2008 - 12:05

Update - found a reliable fix overriding theme_links that works with D5 and Zen, but of course this only applies to theme-generated menu links (at least it takes care of primary/secondary menus).

Cleaned-up version in my comment toward the end:

http://drupal.org/node/140491

Still looking for the more functional solution (based on the URL path rather than the menuing path as described above), any help welcome!

 
 

Drupal is a registered trademark of Dries Buytaert.