菜单类型:
menu_default_local_task()默认显示tab
menu_local_task这种的显示在右侧tab
(tab显示需要最少两个才会显示)
menu_default_item()左侧菜单,一般可以不写
menu_suggested_item() 建议菜单,可以开启的
menu_callback()回调菜单,仅用于调用
/**
* 菜单中选项卡菜单的例子,同时选项卡我们需要至少三件事:
* 1.父菜单的类型是个普通类型 'type' => MENU_NORMAL_ITEM,
* 2.主选项卡(处于活动状态,直接展示在我们面前的那个菜单)。此选项卡是类型 MENU_DEFAULT_LOCAL_TASK。
* 3.一些其他菜单项的其他选项卡,类型 MENU_LOCAL_TASK。
*/
属性:
'access callback' => TRUE, 所有可见
'expanded' => TRUE, //有子菜单
//在路径url中传递参数
$items['examples/menu_example/placeholder_argument/%/display'] = array(
'title' => 'Placeholder Arguments',
'page callback' => '_menu_example_menu_page',
'page arguments' => array(3),
'access callback' => TRUE,
);
/*这个菜单事例上:在菜单路径上带有 ‘ %menu_example_arg_optional’,则会先去找该函数的_load方法,
在本例中回去找 menu_example_arg_optional_load()方法,然后将返回的值作为参数传递给页面回调函数*/
$items['examples/menu_example/default_arg/%menu_example_arg_optional'] = array(
'title' => 'Processed Placeholder Arguments',
'page callback' => '_menu_example_menu_page',
'page arguments' => array(3), // arg 3 (4rd arg) is the one we want.
'access callback' => TRUE,
'weight' => 70,
);
//更改了菜单路径,及其标题
function menu_example_menu_alter(&$items) {
if (!empty($items['examples/menu_example/menu_original_path'])) {
//将原来路径的页面内容赋给新路径,以作为新路径的页面内容
$items['examples/menu_example/menu_altered_path'] = $items['examples/menu_example/menu_original_path'];
//这里更改的是菜单中的标题
$items['examples/menu_example/menu_altered_path']['title'] = 'Menu item altered by hook_menu_alter()';
// 防止页面出现在原始路径 (将该项取消设置)。
unset($items['examples/menu_example/menu_original_path']);
}
//更改用户页面head 中标题
//%user 先去 执行user_load() 这段代码目的是更改用户页面的title,即就是浏览器最顶端的title(head标签中title)可以访问user/id 查看页面标题的变化
if (!empty($items['user/%user'])) {
$items['user/%user']['title callback'] = 'menu_example_user_page_title';
}
}