How to show custom menu in Drupal admin panel

My PM give me task to show subscriber list in Drupal’s admin panel. And he said that admin can edit and delete any record from that list.

I had already created the module subscriber with some code that is being used in site ront. I added new menu item in that module to show subscriber list and wrote related functions to perform desired task. Task was working well but I had one problem. The menu items, I created, was not visible in admin panel like User management, Report etc.

I wanted to show a heading and some menu items. The menu items I have created were visible at different location, in the top of admin panel where By Task and By module link exists.

I opened core user module of Drupal and explored the code, how Drupal is showing menu item with heading in admin panel. I found following code in Drupal’s user module to show a box and menu item.

$items['admin/user'] = array(

'title' => 'User management',

'description' => "Manage your site's users, groups and access to site features.",

'position' => 'left',

'page callback' => 'system_admin_menu_block_page',

'access arguments' => array('access administration pages'),

'file' => 'system.admin.inc',

'file path' => drupal_get_path('module', 'system'),

);

This code shows a Heading and create a box in which Drupal can display child menu items.

I copied and pasted this code in my subscriber module and made some changes that were required to my subscriber module. I refresh the page but there was nothing new. My menu items were not there. Above code only shows a heading and draw a box for child menu items.

If you want some menu to display in this box then you should make path of you menu

items like $items['admin/user/edit'] = array(

Then edit menu item would be show in that box.

But my problem was not that I had done these changes before for my subscriber module.

I was unable to display my custom box in Drupal admin panel. Then I focused on child menu items where I used the type of menu to MENU_LOCAL_TASK I change one of my menu to MENU_NORMAL_ITEM then I refreshed the page and I found thet there is beautiful box with a heading and my custom box is displaying there and I changed type of all menu items to MENU_NORAML_ITEM which I want to display in that box.

You can use MENU_CALLBACK for menu item that is not required to display in menu box.

Faaiq Ahmed PHP Developer in
Arcgate
Created a blog Shopping Camp

Bookmark and Share
There are no comments to this entry yet

Comments are closed.