Skip to main content
1 of 2
Clive
  • 167.9k
  • 19
  • 303
  • 337

Menus and paths are slightly different things...in hook_menu() you're defining paths that can be consumed; menus create the links to those paths - the two concepts aren't necessarily related (a path can exist without a menu link).

You can assign a particular router path to a menu using the menu property in your hook_menu() items, but that menu needs to exist already.

Fortunately Drupal provides a method for adding links to the top of a page through hook_menu(), and you only need to change one line:

$items['admin/custom/add'] = array(
  'title' => t('Add Custom'),
  'decription' => t('Add custom'),
  'page callback' => 'custom_add',
  'access arguments' => array('add custom'),
  'type' => MENU_LOCAL_ACTION, // <-- This one changed
  'file' => 'custom_add.inc',
  'file path' => drupal_get_path('module', 'custom') . '/includes',
);

That will put a link to 'Add Custom' at the top of the 'admin/custom' page; if you're using the Seven theme for administration it'll look like the 'Add Content' link on the content admin page:

enter image description here

Clive
  • 167.9k
  • 19
  • 303
  • 337