doulan4939 2012-01-05 01:39
浏览 34
已采纳

drupal 7中未定义的偏移错误

I tried to implement hook_menu in drupal.

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;
}

However, the code above will case these 2 errors:

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).

The above 2 errors will not show up if i change

'access callback' => 'user_access',

to

'access callback' => TRUE,

But I already login as administrator, and I give the access permission to all users, and I tried to reload the module, tried to reinstall drupal so that make the database clean, but I still got the same errors, any advices?

  • 写回答

1条回答 默认 最新

  • dongying7847 2012-01-05 01:44
    关注

    You spelled "arguments" wrong in the second menu definition.

    'access agruments' => array('receive greeting'),
    

    Should be

    'access arguments' => array('receive greeting'),
    

    When you switched it to 'access callback' => TRUE, it ignored the arguments because it was told that it didn't need to do any checks, but with an actual callback it tried to find the access arguments but can't.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥15 stable diffusion
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条