1

I am trying to show a 3 level tab on the user profile page, but I cannot find a way of doing it. I've managed to get a second level working, on my custom module on drupal 7.

<?php
/**
 *patners page with all the tabs
 */

$items['user/%user/patners'] = array(
    'title' => t('My deals'),
    'description' => t('this is to show patners ther items'),
    'page callback' => 'patners_page',
    'page arguments' => array(1),
    'access arguments' => TRUE,
    'type' =>MENU_LOCAL_TASK,
    'weight'=>-18,
);
$items['user/%user/patners/coupon'] = array(
    'title' =>'??????',
    'page callback' => 'patners_page',
    'page arguments' => array(1),
    'access callback' => TRUE,
    'type' => MENU_DEFAULT_LOCAL_TASK,
);
$items['user/%user/patners/statistics'] = array(
    'title' => '?????????',
    'page callback' => 'partners_statistics',
    'page arguments' => array(1),
    'access callback' => TRUE,
    'type' => MENU_LOCAL_TASK,
);
$items['user/%user/patners/coupon/all'] = array(
    'title' =>'??? ??????',
    'page callback' => 'patners_page',
    'page arguments' => array(1),
    'access callback' => TRUE,
    'type' => MENU_DEFAULT_LOCAL_TASK,
);
$items['user/%user/patners/coupon/used'] = array(
    'title' =>'????????????',
    'page callback' => 'patners_coupon_used',
    'page arguments' => array(1),
    'access callback' => TRUE,
    'type' => MENU_LOCAL_TASK,
);
$items['user/%user/patners/coupon/pending'] = array(
    'title' =>'??????',
    'page callback' => 'patners_pending_coupons',
    'page arguments' => array(1),
    'access callback' => TRUE,
    'type' => MENU_LOCAL_TASK,
);
return $items;
?>
  • You're going to have to be more specific. Drupal version? Any contrib modules? Could you post any custom code so we can see if there are any errors in it? the more information you provide the more likely you are to get a constructive answer. – Chapabu Feb 9 '12 at 13:27
  • @Chapabu I have edited the Question,i have included my code. I am using drupal 7. – mrcniceguy Feb 9 '12 at 16:25
2

Drupal doesn't provide third level local tasks by own. You have to implement it, something like this:

/**
 *  @see: menu_local_tabs()
 */
function my_module_menu_local_tabs() {
  return array(
    '#theme' => 'menu_local_tasks', 
    '#primary' => menu_primary_local_tasks(), 
    '#secondary' => menu_secondary_local_tasks(),
    '#tertiary' => my_module_tertiary_local_tasks(),
  );
}

/**
 * @see: menu_secondary_local_tasks()
 */
function my_module_tertiary_local_tasks() {
  // The index of local task starts from 0, so you need the 2 level of local tasks.
  $links = menu_local_tasks(2);
  // Do not display single tabs.
  return ($links['tabs']['count'] > 1 ? $links['tabs']['output'] : '');
}

function my_module_preprocess_page(&$vars) {
  $variables['tabs'] = my_module_menu_local_tabs();
}

All of this code based on core's localtask generation function, it's normally alterable, translation-ready, access checked:

menu_local_tabs()

menu_secondary_local_tasks()

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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