Hi,
I'd like to change the output of the menu item displayed in MENU_LOCAL_TASK on /user/username for the page "user/username/profile/profile" so that rather than just saying "Profile" it says "Edit Profile". I've done this before for other links using hook_menu_alter in a custom module. However when I attempt to alter the link created by content_profile the link just dissapears.
This is the code that I am using, I should also add that I've enabled "Show a tab at the user's page" on the content profile config page.
function bttsuser_menu_alter(&$menu) {
$menu['user/%user_category/profile/profile']['title'] = "Edit Profile";
}As far as I can tell this code should work, am I missing something really obvious?
Thanks in Advance,
Barry
Comments
Comment #1
gsquirrelI was also trying to do this and so found your post, it did work for me eventually, but only after I realised you have to rebuild the menu for it to take affect. Also on my setup the user id is used rather than the name so the function looks like this (I have two types of profile node):
Comment #2
barry commentedThanks, that seems to have done the job.
Comment #3
ktonini commentedhmm couldn't get this to work. Would you mind posting the final code that you used?
Comment #4
whan commentedIt didn't work for me either. I get access denied error for the altered menu through hook_menu_alter
Thanks
Comment #5
logicexpertise commentedHow do you rebuild the menus?
Comment #6
phacts commentedAt admin/settings/performance, just clear the cache (its at the bottom of the page, assuming you are using Drupal 6.x).
Also, keep in mind, hook_menu_alter was added as of Drupal 6.x. http://api.drupal.org/api/function/hook_menu_alter
I used this to change the title of the user edit page, user view page, and track page, but you get the point. The print_r was so I could see all of the menu items, and get the right ones:
Comment #7
webwriter commentedSorry to be slow but... where exactly does that code go? That is exactly what I am looking for. Thanks!
Comment #8
julie.metivier commentedThank you phacts for this code. It works fine for me.
I've just changed user/%user/track by user/%user/track/navigation.
@webwriter
To use this code, you have just to create a new module by creating a new folder my_module in sites/all/modules/. Then create a file my_module.module and put this code inside. This will work.
Comment #9
webwriter commentedAh- new module. OK, thanks for the explanation!
Comment #10
netentropy commented@6 phacts
I tried your
drupal_set_message('Menu Items: <pre>'.print_r($items, TRUE).'</pre>');and it only shows me the $items for the admin menus in the content portion of the admin sectionhow do you get it to show the arrays for the user tabs?
Comment #11
Buckminster_Bond commentedThanks All
Finally got it to "work".
It was the first time that I've created a module - I found this helpful...(you need to add a .info file for the module to work - this shows how.)
http://www.hankpalan.com/blog/drupal/make-custom-drupal-module
Best Wishes
Comment #12
velpan commented@ whan, try
Comment #13
bluetegu commentedin D7 what worked form me is:
$items['user/%user/edit']['title'] = 'Edit account';
Comment #14
raghukr commentedhttp://drupal.org/project/tabtamer
Comment #15
katrialesser commentedThank you for posting about this module!!