我想在名为“cssswitch”的模块的“node/%/edit”页面中添加一些选项卡。当我单击“重建菜单”时,会显示两个新选项卡,但在编辑它们时会为所有节点显示它们,而不仅仅是节点“cssswitch”。我希望仅在编辑“cssswitch”类型的节点时才显示这些新选项卡。
另一个问题是当我清除所有缓存时,选项卡会从所有编辑页面中完全消失。下面是我写的代码。
function cssswitch_menu_alter(&$items) {
$node = menu_get_object();
//print_r($node);
//echo $node->type; //exit();
if ($node->type == 'cssswitch') {
$items['node/%/edit/schedulenew'] = array(
'title' => 'Schedule1',
'access callback'=>'user_access',
'access arguments'=>array('view cssswitch'),
'page callback' => 'cssswitch_schedule',
'page arguments' => array(1),
'type' => MENU_LOCAL_TASK,
'weight'=>4,
);
$items['node/%/edit/schedulenew2'] = array(
'title' => 'Schedule2',
'access callback'=>'user_access',
'access arguments'=>array('view cssswitch'),
'page callback' => 'cssswitch_test2',
'page arguments' => array(1),
'type' => MENU_LOCAL_TASK,
'weight'=>3,
);
}
}
function cssswitch_test(){
return 'test';
}
function cssswitch_test2(){
return 'test2';
}
谢谢你的帮助。