Drupal hook_menu from module for admin menu

百般思念 提交于 2020-01-07 04:24:27

问题


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.

thanks


回答1:


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

return $items;

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




回答2:


Have you cleared the menu cache yet? Not sure if going to the module page does that.



来源:https://stackoverflow.com/questions/4671626/drupal-hook-menu-from-module-for-admin-menu

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!