来自管理菜单模块的Drupal hook_menu [英] Drupal hook_menu from module for admin menu

查看:89
本文介绍了来自管理菜单模块的Drupal hook_menu的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个自定义模块"menu_mods",用于将菜单项添加到管理菜单.它没有添加.我希望链接显示在导航"菜单中.我在管理页面上使用了Garland主题. 这是我的模块代码:

I have a custom module "menu_mods" for adding menu items to the admin menu. It's not adding it. I want the link to show in the Navigation menu. I'm using the Garland theme for the admin pages. Here is my module code:

function menu_mods_menu() {

    $items = array();

    $items['admin/editfrontpage']=array(
        'title'=>'Edit Homepage',
        'description'=>'Edit Homepage.',
        'page callback' => 'edit_front_page',
        'access callback' => TRUE,
        'type' => MENU_NORMAL_ITEM

    );          
}

function edit_front_page(){
    $frontPageUrl = drupal_get_normal_path(variable_get('site_frontpage', 'node')); // outputs "node/112"
    $frontPageUrl = $frontPageUrl.'/edit';
    drupal_goto($frontPageUrl);
}

有人知道为什么它不显示吗?进行更改后,进入模块页面,然后进入菜单页面.

Any idea why it's not displaying? After I make a change, I go to the modules page and then to the menu page.

谢谢

推荐答案

哇!愚蠢的错误. 我忘了在函数末尾返回$ items.

WOW! Silly mistake. I forgot to return the $items at the end of the function.

返回$ items;

return $items;

顺便说一下,这个小功能为您提供了一个编辑链接,用于编辑网站的首页.

By the way, this little function gives you an edit link to edit the front page of your site.

这篇关于来自管理菜单模块的Drupal hook_menu的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆