0

Can't figure out why two admin pages of my custom module are not showing in different tabs. I've disabled and re-enabled the module, cleared cache, however while both pages are accessible and I see the "Leads" link in the menu, unfortunately they are not aligned into tabs. Can anyone help me to get my tabs?

/**
 * Implementation of hook_menu().
 */

function leads_menu() {
  $items = array();

  $items['admin/commerce/leads'] = array(
    'title' => 'Leads',
    'access arguments' => array('administer leads'),
    'page callback' => 'leads_active',
  );
  $items['admin/commerce/leads/subscribed'] = array(
    'title' => 'Subscribed Leads',
    'page callback' => 'leads_subscribed',
    'type' => MENU_DEFAULT_LOCAL_TASK,
    'weight' => -10,
  );

  return $items;
}

1 Answer 1

2

It seems that first main path 'admin/commerce/leads' needs to be defined, and then other two items added. The first item inherits the properties of the main menu item, and the second defines its own callbacks. Far from obvious, but it works for me now:

  function leads_menu() {
  $items = array();

  $items['admin/commerce/leads'] = array(
    'title' => 'Leads',
    'access arguments' => array('administer leads'),
    'page callback' => 'leads_active',
  );
  $items['admin/commerce/leads/active'] = array(
    'title' => 'Active',
    'type' => MENU_DEFAULT_LOCAL_TASK,
    'weight' => -10,
  );
  $items['admin/commerce/leads/subscribed'] = array(
    'title' => 'Subscribed',
    'page callback' => 'leads_subscribed',
    'type' => MENU_LOCAL_TASK,
    'access arguments' => array('administer leads'),
  );

  return $items;
}
1
  • 1
    This is correct. When in doubt, look at what Drupal core modules do. The Node module defines node, node/%node/view, and node/%node/edit.
    – avpaderno
    Commented Nov 30, 2015 at 6:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.