Hello, I've created a menu link titled "My Account" which, using menu token, leads to "user/%uid/edit". Allthough when I log with my account (admin) it all works fine, when I log with another account that doesn't have admin rights, the title is Drupal's default "Edit" (which is the tab title for user/%/edit), and the link isn't the active trail. Any help with that? Am I missing something?

Comments

segi’s picture

Version: 7.x-1.0-beta1 » 7.x-1.0-beta4

I have the same problem with beta4 version. I use the same path(edit page) and when I set a different Menu item title as Edit, then the menu item drop the own title and use the user/%user/edit page's title. I found another problem, that this menu item titles don't go through t() function, so every time get back the original English text.

queenvictoria’s picture

Version: 7.x-1.0-beta4 » 7.x-1.x-dev

This is also a problem in 7.x-1.x-dev

chrlvclaudiu’s picture

Version: 7.x-1.x-dev » 7.x-1.0-beta4

Yes, seems like it's saving the title for the current user's path.

For instance I'm trying to set a different title for the "user/%/edit" router name and replace it with "user/[current-user:uid]/edit", but after I checked the table "menu_links" for that specific menu link id, "link_path" column shows "user/1/edit" (1 for admin).

My guess is that when the menu item is saved with this token, he replaces the [current-user:uid] token with the ID of the currently logged in user. While being logged in as administrator saw the menu title was correct.

chrisarusso’s picture

I just implemented a work around using hook_menu_alter() like so:

/*
 * Implements hook_menu_alter()
 */
function example_menu_alter(&$items) {
  $items['user/%user/edit']['title'] = t('Custom text');
}
dasjo’s picture

jesse.d’s picture

Is there a reason that you couldn't change line 118 in menu_token.module?

Currently:

$item['title'] = token_replace($item['title'], $data, $options);

Fixed (at least for the 'user/%/edit' path):

$item['title'] = token_replace($item['link_title'], $data, $options);

I'm not exactly sure what the effects are on other menu items though or why $item['title'] was choosen originally.

Mazzhe’s picture

I had a similar issue:
I created a menu item like this: user/[current-user:uid]/cv, and I wanted the title to be «My CV», but it was «My account».

I changed line 118, as jesse.d suggested in #6, and now the title I chose is shown.
Thanks !

pravin ajaaz’s picture

Version: 7.x-1.0-beta4 » 7.x-1.x-dev
Status: Active » Needs review
StatusFileSize
new639 bytes

Patch for the same.

daniel wentsch’s picture

Thanks jesse & Pravin,

what a mean bug, especially because user 1 doesn't see the wrong menu item. #8 fixed it for me, too.

  • develCuy committed bdb3dec on 7.x-1.x authored by Pravin Ajaaz
    Issue #1604880 by Pravin Ajaaz, jesse.d: Override user/%uid/edit title
    
develcuy’s picture

Status: Needs review » Reviewed & tested by the community

Thanks for testing @Daniel Wentsch

develcuy’s picture

Status: Reviewed & tested by the community » Needs review

Patch at #8 committed, please help me test, if somebody complains I'll revert the patch.

develcuy’s picture

Status: Needs review » Fixed

Nobody complains after 3 weeks. Thanks everyone!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.