Drupal 7: Add a custom link in admin menu

User login

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