Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I really need the active trail classes to be applied to my menus, as discussed in 219804, but I don't want to use the dev branch of the module for a production site. Issue 219804 includes a patch for 6.x-2.x (http://drupal.org/node/219804#comment-1131533) which I've backported to 6.x-1.3
Comment | File | Size | Author |
---|---|---|---|
#11 | nice_menus-465738-11.patch | 3.41 KB | osopolar |
#1 | nice_menus-active-path_465738-1.patch | 3.07 KB | Mark B |
Comments
Comment #1
Mark B CreditAttribution: Mark B commentedComment #2
fei CreditAttribution: fei commentedThank you! I'll drop a msg if I run across any problems with this patch.
The site I'm using this for will be going up in a week or two and this is one of the few issues left. Thanks!
Comment #3
peterjmag CreditAttribution: peterjmag commentedThis is exactly what I needed for a couple of sites that I'm getting ready to launch. I was even considering launching them with the 2.x dev version of nice_menus installed just for this capability, which is just bad form.
I applied the patch successfully on one of my simpler D6 sites. I'll try it out on my larger almost-launched sites and let you know if I have any problems.
Many thanks to you and add1sun!
Comment #4
asak CreditAttribution: asak commentedMark, this is strange. I've applied the patch - but nothing changes. everything works as it did. cleared all caches and saved the modules page, but nothing. I would expect it not to work if something was wrong - not to work as it did before the patch ;)
Clues...?
I'll play around some more...
Comment #5
asak CreditAttribution: asak commentedOk found it...
This patch successfully adds an 'active' class to menuparents - but not to menu items which are not parents.
To fix, i added these line:
again just before the second output in the file, which after applying the patch above becomes line 365, so the function now looks as such:
Comment #6
nielt CreditAttribution: nielt commentedFor anyone wondering, the change made in #5 by asak is included in the patch in #1.
This works fine for me. Thank you asak and Mark B!
Comment #7
jacobkdavis CreditAttribution: jacobkdavis commentedThanks a lot for this patch, I was surprised this wasn't included in the module.
Contrary to #6's comment, when I just patched using #1 it was still only setting the active class on menu items that were parents / had submenu items. I had to replace the entire function with the function from #5 to get it to work for menu items that didnt have any children.
Thanks again everybody!
Comment #8
echoz CreditAttribution: echoz commentedFor my use, I didn't need the additional change added in #5 because on non menuparent items, we still have the active class on the anchor tag itself, and I'm targeting the anchor tag anyway. This might explain why some users didn't need this.
Comment #9
rockdw CreditAttribution: rockdw commentedI have to apologize in advance, I don't really know the correct way to comment on this. :-)
I had to add the $trail_class to the final output to get it to work, otherwise, the info in #5 doesn't ever use it:
Old line:
$output .= '<li id="menu-'. $mlid .'" class="'. $path_class .'">'. theme('menu_item_link', $menu_item['link']) .'</li>'."\n";
New line:
$output .= '<li id="menu-'. $mlid .'" class="'. $trail_class . $path_class .'">'. theme('menu_item_link', $menu_item['link']) .'</li>'."\n";
There seems to be a discrepency between what's in the patch and what's in #5. but when I added the first part of #5 and then also the updated output line to the patched code from #1, it worked for me.
Comment #10
add1sun CreditAttribution: add1sun commentedthis needs an updated patch then
Comment #11
osopolarThe patch above and the changes in #5 (and #9) are working fine for me.
I've created a patch. Please review and hopefully commit it to the next stable 6.x-1.4 release. Thanks.
Comment #12
amogiz CreditAttribution: amogiz commentedWonderfful ! I was exactly looking for this for many weeks. Thanx :)
Comment #13
john.kenney CreditAttribution: john.kenney commentedi gather other people have successfully gotten these patches to work, but i tried both tonight and neither one worked for me.
1st patch resulted in entire menu disappearing completely.
2nd patch resulted in no visible change to existing menus.
i think i am doing it correctly, but i'm no whiz at patching.
i get no hunk fails. looks to patch correctly. i checked the physical file and the changes appear to have been made (though I didn't examine every single line).
am using cygwin on windows vista 64 machine.
perhaps i will just upgrade to the dev version.
Comment #14
VladRM CreditAttribution: VladRM commentedThanks for the patch ositoblanco. It works great. Hope to see it in 6.x-1.4.
Comment #15
john.kenney CreditAttribution: john.kenney commentedtried again. worked!!
i'm a patching newbie, so must have done something wrong in earlier attempt.
Comment #16
nicholas.alipaz CreditAttribution: nicholas.alipaz commentedGreat patch, works wonderfully! even when using in one's own theme's template.php doing some overrides.
Comment #17
nicholas.alipaz CreditAttribution: nicholas.alipaz commentedjust looking a bit more, it seems that it does not work when items are more than one level deep.
Example 1:
Example 2:
Example 1 displays the proper active trails when the bolded item is active, but example 2 does not display correct active trails when the bolded menu item is active.
Comment #18
john.kenney CreditAttribution: john.kenney commentedmight be a CSS issue. i had to fiddle with mine to get it to work properly at each level, but now it does. i have 3 level menus like you.
you can look at mine in case that helps: http://www.aboutcallingcards.com/callingcard-review
as with other nice_menu css, it was a bit of a project to get it exactly right.
Comment #19
nicholas.alipaz CreditAttribution: nicholas.alipaz commentedI doubt it would be a css issue as the active-trail and active classes are output via php.
Comment #20
john.kenney CreditAttribution: john.kenney commentedoh, you are saying the classes are simply not present to style against. i misunderstood.
Comment #21
nicholas.alipaz CreditAttribution: nicholas.alipaz commentedIt is however interesting that your site seems to be outputting the classes. It may have to do with some sort of difference between placing the theme function within one's template.php file or not. I have it in my template.php so that I could add an extra span to each link.
Comment #22
john.kenney CreditAttribution: john.kenney commentedi simply patched the module. perhaps try that to see if it works? putting it in template.php is well beyond my technical know how, so can't help you there.
Comment #23
nicholas.alipaz CreditAttribution: nicholas.alipaz commentedwell, I applied the patch to my module already. Then I copied out the modified/patched theme function and put it in my template.php. It doesn't seem to be working correctly when doing that.
Comment #24
greg.harveyWorks fine for me. I suspect something else is interfering with your active trail, nicholas. =/
Are you overriding any of the theme functions in template.php of your theme, by any chance? Could have old copies sticking in there?
Setting back to R&TBC, since it works for amogiz, VladRM, John and it works for me.
Comment #25
nicholas.alipaz CreditAttribution: nicholas.alipaz commentedCan anyone confirm that the menuitems show "activetrail" classes when the "active" menuitem is two levels deep? Like my previous example:
Example 1 (works, all classes show within my links properly):
Example 2 (doesn't work, active-trail classes are not shown on any parents):
Comment #26
greg.harvey@nicholas.alipaz I can confirm Example 2 works for me. I'm going to load that on to our client preview server later - I'll send you a link via the contact form so you can see for yourself. Your problem is very strange... I don't have it at all. =/
Comment #27
john.kenney CreditAttribution: john.kenney commentedlikewise, #2 works for me -- as you saw on the link i gave you earlier.
i am not clear if, at this point, you have installed only the module -- or are still making modifications to template.php, as well. and i'm sure you've tried clearing caches and so forth to ensure you are seeing the thing clean. otherwise, no idea.
Comment #28
nicholas.alipaz CreditAttribution: nicholas.alipaz commentedI am actually using this modified theme function, but don't really expect any help on it, since it has been pretty heavily modified. This is in my theme's template.php
BTW, wouldn't it be better if the theme function we have here did more like what I have done in my theme function?
classes[] = ....
instead of concatenating them together as a string as we go along?Comment #29
Prasad Shir CreditAttribution: Prasad Shir commentedI was facing same problem - Nice Menus not showing "active-trail" class. Spent few hours searching for solution. Patch at #1 worked like a charm!!
Thanks a lot for the solution!!
Comment #30
ambientdrup CreditAttribution: ambientdrup commentedTrying the patch from post #1 and then getting this error:
warning: Missing argument 2 for theme_nice_menu_build() in /mnt/stor1-wc2-dfw1/445745/www.site.com/web/content/sites/all/modules/nice_menus/nice_menus.module on line 337.
Any suggestions?
-Trevor
Comment #31
greg.harvey@ambientdrup: Use the patch in #11 against the 6.x-1.3 version.
Comment #32
ambientdrup CreditAttribution: ambientdrup commentedOk, I must have not applied the patch correctly first try. I tried it again and it's not throwing errors now ... however my parent elements are still not highlighting as active per this new patch. It's doing exactly what it did before applying the patch (not active).
Do I need to add something else?
-Trevor
Comment #33
ambientdrup CreditAttribution: ambientdrup commentedHmmm ... ok I did that but it just loads a blank white screen on the site now. I must not be applying that one correctly?
I'll try it again.
-Trevor
Comment #34
ambientdrup CreditAttribution: ambientdrup commentedOk, hmmm ... I applied the patch successfully from #11 but it's still not working. Child elements are active but the parent items are not.
-Trevor
Comment #35
ambientdrup CreditAttribution: ambientdrup commentedOk, it's working now. I needed to fiddle with my CSS per #18.
Works like a charm now!
Thanks!
-Trevor
Comment #36
CrashNet CreditAttribution: CrashNet commentedSubscribing.
Comment #37
redpuma CreditAttribution: redpuma commentedApplied patch from #11 and works fine. Thanks ositoblanco (*not tested against 3 level nav as yet)
Comment #38
dman CreditAttribution: dman commentedThanks for #11. Works fine, I had a tree 6 levels deep.
Comment #39
robbertnl CreditAttribution: robbertnl commentedUsing #11 (http://drupal.org/node/465738#comment-2027028) as well. Will report errors here if I find some.
Comment #40
add1sun CreditAttribution: add1sun commentedJust setting status to backport so it gets of my RTBC radar. ;-) Leaving it open so that folks who want it can find it.
Comment #41
metaprinter CreditAttribution: metaprinter commentedCan you please give me a little help on how I implement this patch? Thank you.
Never mind. I got it. using http://drupal.org/patch/create and http://drupal.org/node/60818
Comment #42
matt2000 CreditAttribution: matt2000 commentedFixed my own hacked up version based on #11. Thanks.
[x] subscribe
Comment #43
yan CreditAttribution: yan commented#11 works as intended!
Comment #44
pianomansam CreditAttribution: pianomansam commentedPatch from #11 confirmed once more to solve this problem. PLEASE commit!
Comment #45
add1sun CreditAttribution: add1sun commentedThis will not be committed to the 1.x branch. This feature is in the 2.x version and 1.x will no longer be supported. Since the 2.x is working well and getting close to a stable, I'm not going to add features to old code. I'm going to won't fix this now since people really need to be moving on to 2.x. ;-)
Comment #46
redpuma CreditAttribution: redpuma commentedWhy not patch it while 2.x is still beta?
Nobody wants to put a beta onto a production site. Save all the people that use the official release having to go through the same rigmarole as everybody above?
Comment #47
dman CreditAttribution: dman commented> This feature is in the 2.x version
Comment #48
redpuma CreditAttribution: redpuma commented> 2.x is still beta
Comment #49
Danny_Joris CreditAttribution: Danny_Joris commentedI agree on the beta sentiment. If I had known that the beta version had all the newest bug fixes and the official 1.6 release doesn't, I would have downloaded the beta version.
Comment #50
mandclu CreditAttribution: mandclu commentedIf you want people moving to 2.x, mark it as stable.
+1 for committing this to the 1.x branch.
Comment #51
Anonymous (not verified) CreditAttribution: Anonymous commentedCommit this! Seriously, it's pretty annoying having to dig around for the solution in the issues cue and apply a patch when it's existed for over a year now.