views:

37

answers:

1

hi,

I need to add a menu item with the following link: user/16/addresses

It is the link to a tab of user profiles. Of course 16 is the user ID and it should change according to the user.

Can I use tokens directly into menu items ? such as [uid] ?

thanks

+2  A: 

hook_menu() does most of the work for you with this.

function example_menu() {
  return array(
  'user/%/addressess' => array(
      'title' => 'User Addresses',
      'page callback' => 'example_callback',
      'page arguments' => array(1),
      'weight' => 2,
      'type' => MENU_LOCAL_TASK,
    ),
  );
 }

This will add the tab when you are on a user page and put the UID in the URL.

As I understand it the MENU_LOCAL_TASK works off the current URL, so you couldn't substitute another USER id into the menu with this.

Jeremy French
`MENU_LOCAL_TASK` makes the menu appear as a new tab in the page; you can use it for pages that already have a menu marked as `MENU_DEFAULT_LOCAL_TASK`, which is `user/%/view`, in this case.
kiamlaluno

related questions