Drupal 7: Add a custom link in admin menu

Here is some code to be used in a custom module in Drupal 7 in order to create a custom link in the admin menu. This item will show up in the Configuration section and it is particularly useful with the administration menu module.

<?php
function MYMODULE_menu () {
 
$items = array();
 
$items['admin/config/parent-name'] = array(
     
'title' => 'My Item Parent Name',
     
'description' => 'My Description',
     
'position' => 'left',
     
'weight' => -100,
     
'page callback' => 'system_admin_menu_block_page',
     
'access arguments' => array('administer site configuration'),
     
'file' => 'system.admin.inc',
     
'file path' => drupal_get_path('module', 'system'),
  );
 
//We need at least one child item, otherwise parent will not show up
 
$items['admin/config/parent-name/child-name'] = array(
     
'title' => 'My Item Child Name',
     
'description' => 'My Description',
     
'page callback' => 'drupal_goto',
     
'page arguments' => array('my-path'),
     
'access arguments' => array('administer site configuration'),
  );
  return
$items;
}
?>

Tags: 
Drupal 7

Recent Comments

Forward by Dries Buytaert, Founder and Project Lead, Drupal; CTO Acquia.

Order now from:

Managing Expectations Podcast with DrupalEasy

Author Interview http://tinyurl.com/8a8nxno

We provide the most Shiny Drupal Bits & Pixels

Since Drupal 4.x