Drupal:水平菜单
我正在尝试以编程方式为我的自定义模块创建自定义水平菜单,但遇到了很多麻烦。
我想制作一个像这样的水平菜单:
这是到目前为止我的代码,但它只显示在主要的左侧垂直侧边栏以及其他所有内容(这是预先打包的 Garland 主题):
/* hook_menu implementation for my 'lab' custom module */
function lab_menu() {
$items = array();
$items['lab/admin'] = array(
'title' => 'LAB Admin',
'page callback' => 'some_method',
'access arguments' => array('access content'),
'access callback' => 'user_access',
'type' => MENU_NORMAL_ITEM,
);
/* should appear as a 'tabbed' horizontal method */
$items['lab/admin/appoint'] = array(
'title' => 'LAB: Appointment',
'page callback' => 'some_method',
'page arguments' => array(1),
'access callback' => 'node_access',
'access arguments' => array('view', 1),
'type' => MENU_NORMAL_ITEM,
);
$items['lab/admin/reviewers'] = array(
'title' => 'Reviewer\'s Link',
'page callback' => 'some_method',
'page arguments' => array(1),
'access callback' => 'node_access',
'access arguments' => array('view', 1),
'type' => MENU_NORMAL_ITEM,
);
return $items;
}
I'm trying to programmatically create the custom horizontal menu for my custom module, but I'm having a lot of trouble.
I want to make a horizontal menu like this :
This is my code so far, but it only displays on the main left vertical sidebar with everything else (this is the pre-packaged Garland theme):
/* hook_menu implementation for my 'lab' custom module */
function lab_menu() {
$items = array();
$items['lab/admin'] = array(
'title' => 'LAB Admin',
'page callback' => 'some_method',
'access arguments' => array('access content'),
'access callback' => 'user_access',
'type' => MENU_NORMAL_ITEM,
);
/* should appear as a 'tabbed' horizontal method */
$items['lab/admin/appoint'] = array(
'title' => 'LAB: Appointment',
'page callback' => 'some_method',
'page arguments' => array(1),
'access callback' => 'node_access',
'access arguments' => array('view', 1),
'type' => MENU_NORMAL_ITEM,
);
$items['lab/admin/reviewers'] = array(
'title' => 'Reviewer\'s Link',
'page callback' => 'some_method',
'page arguments' => array(1),
'access callback' => 'node_access',
'access arguments' => array('view', 1),
'type' => MENU_NORMAL_ITEM,
);
return $items;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
像这样的选项卡显示在用户页面、节点等上。
要在自定义模块中创建如上图所示的“选项卡”菜单,请使用
'type' => MENU_LOCAL_TASK
将其定义为页面上的选项卡。要创建第二级选项卡,请使用
'type' => 的组合MENU_LOCAL_TASK
和'type' => MENU_DEFAULT_LOCAL_TASK
Tabs like these are shown on user pages, nodes, etc.
To create a "tabs" menu like shown in the picture above in your custom module, use
'type' => MENU_LOCAL_TASK
to define it as a tab on a page.To create a second level of tabs, use a combination of
'type' => MENU_LOCAL_TASK
and'type' => MENU_DEFAULT_LOCAL_TASK