Closed (duplicate)
Project:
Drupal core
Version:
7.x-dev
Component:
menu system
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
27 Sep 2011 at 17:55 UTC
Updated:
30 Aug 2020 at 00:03 UTC
Jump to comment: Most recent
Comments
Comment #1
nick_vhWe (together with randy) reproduced this issue and I tried finding documentation about how to set a certain item as active
http://api.drupal.org/api/drupal/includes--menu.inc/function/menu_set_ac...
Also, in further investigation we found that the active link logic happens in function menu_navigation_links
http://api.drupal.org/api/drupal/includes--menu.inc/function/menu_naviga...
The output of the debug session we held gave the following results :
The logic is expecting the path to be
user/1 (user/%user)
But instead the link that we click on to go to my account is
user
There is some automatic magic going on in redirect /user to /user/%user and therefore I guess the active link is not set
Comment #2
jeckman commentedReproduced with fresh install of Drupal 7.8, no additional modules, Bartik theme.
Same symptoms as described. Tried with clean urls enabled and disabled.
The classes assigned are:
Comment #3
pandersb commentedHad to add a module with hook_menu_alter() and then enable the menu link. The active trail finally came through.
Comment #4
Ghostthinker commented#3 not working for me, did you change your custom module weight?
Comment #5
netboss commentedAdding this function to my template.php worked for me:
I know this is kind of "hacky", but it solved my problem.
Hopefully this help!
Comment #6
Ghostthinker commented@netboss thank you. Works for me. Here is a slighly modified version that also respects user/*
This works for me. Maybe there should be a menu_set_active_trail somewhere if you have a user submenu (not tabs).
Comment #7
Abbass commentednone of the above works for me, however setting in the css header-menu ul.menu li.active-trail works for the other tabs of my Main menu
Comment #8
inventlogic commented#6 combined with #5 placed in template.php works for me.
Anyway of adding the .active-trail as well?
Comment #9
ñull commentedConfirming the same bug with Sasson theme. Subscribing and bumping.
#5 nor #6 are working for me.
Comment #10
chanderbhushan commentedYou can put this css :--
#header-menu .content > ul > li.active-trail > a,
#header-menu .content > ul > li > a.active {
color: #1a272e;
background-color: #f8f8f8;
font-weight: 700;
}
OR
You can add unique class through php code :
Comment #11
sunI may be mistaken, but this sounds like a duplicate of #1564388: "My account" link is never in the active trail
Comment #12
warmth commentedOn #5 you can add
<?php global $user; ?>and replace
<?php drupal_match_path(current_path(),"user/*") ?>with
<?php drupal_match_path(current_path(),"user/".$user->uid) ?>to only get that behavior for the current user on his profile.
Comment #13
WorldFallz commentedJust an update that combines 5,6, &12 (you don't need the
global $user):This shows "My Account" on the user's profile page, but leaves it alone for other user profiles.
Comment #14
hkirsman commented#13 worked for me!
Comment #15
danabel commented#13 worked great for me until I added a sub page to the menu item and it didn't show up as a child when the menu item was active.
As a solution I have installed the menu_token module and set the URL to
user/[current-user:uid]. This way everything works as expected including sub-menus. Also if the current-user token doesn't exist the menu item isn't displayed which is perfect for my needs.Comment #16
jweirather commented#13 worked great for me to highlight the menu item for /user for the user path with the active menu classes for active or active-trail, such that when a user visits the /user page, the corresponding menu item for the user account is highlighted as active.
In template.php, wrapped in a hook like in earlier posts. Adding my final code and some keywords ^^^:
It seems odd to me that this doesn't happen OOTB.
Comment #17
jweirather commentedDid not mean to update version. 7.x dev is all that's showing available now.