将3个自定义菜单链接添加到导航菜单

时间:2015-06-01 23:21:37

标签: drupal-7 hook-menu

我正在使用Drupal 7,我想在导航菜单中添加3个菜单链接。这些链接基于当前登录用户的“uid”,但我无法让它工作。我已经检查了这个网站,并且示例使用自定义模块来实现。我想把它添加到我的template.php页面。

这是我现在所拥有的。

function mytheme_menu() {
  $items = array();

  $items['user/%uid/following'] = array(
    'title' => 'My Following Content',
    'description' => 'View the item',
    'type' => MENU_NORMAL_ITEM,
    'menu_name' => 'navigation',
    'access callback' => 'user_is_logged_in',  // TRUE, 'user_is_logged_in' or user_is_anonymous to check if logged in
    'expanded' => TRUE,
  );

  $items['user/%uid/created'] = array(
    'title' => 'My Created Content',
    'description' => 'Item members',
    'type' => MENU_NORMAL_ITEM,
    'menu_name' => 'navigation',
    'page callback' => views_page('individual_item', 'item_members'),
    'access callback' => 'user_is_logged_in',  // TRUE, 'user_is_logged_in' or user_is_anonymous to check if logged in
    'expanded' => TRUE,
  );

  $items['user/%uid/interacted'] = array(
    'title' => 'My Interacted Content',
    'description' => 'All the Content for this item',
    'menu_name' => 'navigation',
    'type' => MENU_NORMAL_ITEM,  
    'page callback' => views_page('individual_item', 'item_content'),
    'access callback' => 'user_is_logged_in',  // TRUE, 'user_is_logged_in' or user_is_anonymous to check if logged in
    'expanded' => TRUE,
  );
   return $items;
}

1 个答案:

答案 0 :(得分:0)

你就在Brad,你只能在自定义模块中实现hook_menu()。

你可以按照这样的方式创建一个简单的自定义模块,并将你的custom_module_menu()函数放在.module文件中。 https://www.drupal.org/node/778734

相关问题