duanjing4623 2011-11-24 15:01
浏览 62
已采纳

drupal 7 hook_menu()无法正常工作

I am trying to add a section to the Home>Administration>Configuration page which then opens a new form with 2 tabs (create_team and create_game).

My code (which does not work):

function guild_management_core_menu()
{           
$items['admin/config/guild_management_core/create_game'] = array
(
    'title' => 'Create Game',
    'description' => 'Create Game',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('guild_management_core_create_game'),
    'access arguments' => array('access administration pages'),
    'type' => MENU_DEFAULT_LOCAL_TASK,
    'weight' => 0,
);      
$items['admin/config/guild_management_core/create_team'] = array
(
    'title' => 'Create Team',
    'description' => 'Create Team',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('guild_management_core_create_team'),
    'access arguments' => array('access administration pages'),
    'type' => MENU_LOCAL_TASK,
    'weight' => 0,
);  

return $items;

}

I tried the links below but they don't work either: drupal--hook_menu Drupal hook_menu from module for admin menu

I also disabled the module and enabled it again and then I cleared the cache but still no results.

EDIT: This works:

$items['admin/config/annotate'] = array(
    'title' => 'Guild Management',
    'description' => 'Guild Management',
    'position' => 'right',
    'weight' => -5,
    'page callback' => 'system_admin_menu_block_page',
    'access arguments' => array('administer site configuration'),
    'file' => 'system.admin.inc',
    'file path' => drupal_get_path('module', 'system'),
  );

When I replace "admin/config/annotate" with "admin/config/guild_management_core" it goes wrong again...

  • 写回答

2条回答 默认 最新

  • dthyxna3894 2011-11-24 15:56
    关注

    UPDATED

    This should work for you:

    function tbff_promo_menu() {
        $items['admin/config/guild_management'] = array(
            'title' => 'Create Game',
            'description' => 'Create Game.',
            'position' => 'right',
            'weight' => -20,
            'page callback' => 'system_admin_menu_block_page',
            'access arguments' => array('access administration pages'),
            'file' => 'system.admin.inc',
        );
        $items['admin/config/guild_management/core'] = array(
            'title' => 'Create Game',
            'description' => 'Create Game',
            'page callback' => 'drupal_get_form',
            'page arguments' => array('search_block_form'),
            'access arguments' => array('access administration pages'),
            'type' => MENU_NORMAL_ITEM
        );
        $items['admin/config/guild_management/core/create_game'] = array(
            'title' => 'Create Game',
            'type' => MENU_DEFAULT_LOCAL_TASK,
            'weight' => 0
        );
        $items['admin/config/guild_management/core/create_team'] = array(
            'title' => 'Create Team',
            'description' => 'Create Team',
            'page callback' => 'drupal_get_form',
            'page arguments' => array('search_block_form'),
            'access arguments' => array('access administration pages'),
            'type' => MENU_LOCAL_TASK,
            'weight' => 0,
        );
        return $items;
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥30 关于用python写支付宝扫码付异步通知收不到的问题
  • ¥50 vue组件中无法正确接收并处理axios请求
  • ¥15 隐藏系统界面pdf的打印、下载按钮
  • ¥15 MATLAB联合adams仿真卡死如何解决(代码模型无问题)
  • ¥15 基于pso参数优化的LightGBM分类模型
  • ¥15 安装Paddleocr时报错无法解决
  • ¥15 python中transformers可以正常下载,但是没有办法使用pipeline
  • ¥50 分布式追踪trace异常问题
  • ¥15 人在外地出差,速帮一点点
  • ¥15 如何使用canvas在图片上进行如下的标注,以下代码不起作用,如何修改