开发者

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 开发者_如何学Citems ? such as [uid] ?

thanks


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜