Php drupal 7中未定义的偏移错误
我尝试在drupal中实现hook_菜单Php drupal 7中未定义的偏移错误,php,drupal-7,Php,Drupal 7,我尝试在drupal中实现hook_菜单 function menufun_menu() { $items['menufun'] = array( 'title' => 'Menu Fun', 'title callback' => 'menufun_title', 'page callback' => 'menufun_greeting', 'file' => 'menufun_greeting.i
function menufun_menu() {
$items['menufun'] = array(
'title' => 'Menu Fun',
'title callback' => 'menufun_title',
'page callback' => 'menufun_greeting',
'file' => 'menufun_greeting.inc',
'page arguments' => array('aaa', 'bbb', 'ccc', 'ddd'),
'access callback' => 'user_access',
'access arguments' => array('receive greeting'),
'type' => MENU_NORMAL_ITEM,
'weight' => -1,
);
$items['menufun/farewell'] = array(
'title' => 'Farewell',
'page callback' => 'menufun_farewell',
'file' => 'menufun_greeting.inc',
'access callback' => 'user_access',
'access agruments' => array('receive greeting'),
'type' => MENU_NORMAL_ITEM,
);
return $items;
}
但是,上面的代码将处理以下两个错误:
Notice: Undefined offset: 0 in _menu_check_access() (line 619 of /Applications/XAMPP/xamppfiles/htdocs/drupal/includes/menu.inc).
Notice: Undefined offset: 1 in _menu_check_access() (line 619 of /Applications/XAMPP/xamppfiles/htdocs/drupal/includes/menu.inc).
如果我更改,上述两个错误将不会显示
'access callback' => 'user_access',
到
但是我已经以管理员身份登录了,我给了所有用户访问权限,我尝试重新加载模块,尝试重新安装drupal以使数据库干净,但我仍然收到相同的错误,有什么建议吗?您在第二个菜单定义中拼写的“参数”错误
'access agruments' => array('receive greeting'),
应该是
'access arguments' => array('receive greeting'),
当您将其切换到
'access callback'=>TRUE时,
它忽略了参数,因为它被告知不需要进行任何检查,但在实际的回调中,它尝试查找访问参数,但无法找到 很乐意帮忙!如果答案有效,不要忘记将其标记为已接受,这样未来的人就会知道这是解决你问题的方法。
'access arguments' => array('receive greeting'),