Search code examples
drupaldrupal-6hook-menu

Drupal: menu items tokens?


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


Solution

  • 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.