2

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

apaderno
  • 28,547
  • 16
  • 75
  • 90
aneuryzm
  • 63,052
  • 100
  • 273
  • 488

1 Answers1

2

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
  • 11,707
  • 6
  • 46
  • 71
  • 1
    `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. – apaderno Jul 09 '10 at 12:19