MENU_LOCAL_TASK 问题

发布于 2024-09-14 17:51:21 字数 352 浏览 1 评论 0原文

我试图在 drupal 中的菜单中添加一个选项卡并使用此功能来测试它:

function my_module_menu() {
  $items['user/%user/classifieds'] = array(
    'title' => 'Action',
    'type' => MENU_LOCAL_TASK,
    'page callback' => 'my_module_page',
    'page arguments' => array(1),
    'weight' => 2,
  );
  return $items;
}

但没有显示任何内容。为什么?

I am trying to add a tab to my menu in drupal and use this function, to test it:

function my_module_menu() {
  $items['user/%user/classifieds'] = array(
    'title' => 'Action',
    'type' => MENU_LOCAL_TASK,
    'page callback' => 'my_module_page',
    'page arguments' => array(1),
    'weight' => 2,
  );
  return $items;
}

But nothing shows up. Why?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

扬花落满肩 2024-09-21 17:51:21

您需要一个访问回调,或者至少需要访问参数访问回调默认为user_access()如果未定义):

function my_module_menu() {
  $items['user/%user/classifieds'] = array(
    'title' => 'Action',
    'type' => MENU_LOCAL_TASK,
    'page callback' => 'my_module_page',
    'page arguments' => array(1),
    'access arguments' => array('access content'),
    'weight' => 2,
  );
  return $items;
}

在对 hook_menu() 进行更改时,还要确保重建菜单或清除缓存。

You need an access callback, or at the very least, access arguments (access callback defaults to user_access() if not defined):

function my_module_menu() {
  $items['user/%user/classifieds'] = array(
    'title' => 'Action',
    'type' => MENU_LOCAL_TASK,
    'page callback' => 'my_module_page',
    'page arguments' => array(1),
    'access arguments' => array('access content'),
    'weight' => 2,
  );
  return $items;
}

Also make sure to rebuild the menu or clear the cache when making changes to hook_menu().

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文