Blog Archive

Tuesday, 28 January 2014

Drupal 7 hook_menu with tab

The following code is the example of hook_menu with tabs
/**
 * Implements hook_menu().
 */
function eventstab_menu() {
  $items['my-events'] = array(
    'title' => 'My events',
    'menu_name' => 'main-menu',
    'type' => MENU_CALLBACK,
    'page callback' => 'drupal_get_form',
    'page arguments' => array('my_events'),
    'access arguments' => array('access my events page'),
  );
  $items['my-events/technology'] = array(
    'title' => 'Technology',
    'type' => MENU_DEFAULT_LOCAL_TASK,
    'page callback' => 'drupal_get_form',
    'page arguments' => array('my_events_technology'),
    'weight' => -10
  );
  $items['my-events/business'] = array(
    'title' => 'Business',
    'type' => MENU_LOCAL_TASK,
    'page callback' => 'drupal_get_form',
    'page arguments' => array('my_events_business'),
    'access arguments' => array('access my events page')
  );
  $items['my-events/lifestyle'] = array(
    'title' => 'lifestyle',
    'type' => MENU_LOCAL_TASK,
    'page callback' => 'drupal_get_form',
    'page arguments' => array('my_events_lifestyle'),
    'access arguments' => array('access my events page')
  );
  return $items;
}

No comments:

Post a Comment