1

I have created tabs in module for different functions. As per code shown below, all the tabs are shown simultaneouly when I login to the module. But, I want to show specific modules depending on the play formats, how can I do that? I tried hook for menu_alter and created custom module but all hides specific menu directly and not condition wise.

Play URLs

$items['abc/play'] = array(
    'title' => t('Welcome Player'),
    'access arguments' => array('administer users'),
    'page callback' => 'drupal_get_form',
    'page arguments' => array('score_entry_table'),
    'access callback' => TRUE,
    'file' => 'scoreentry.inc',
);

$items['abc/play/cricket_score'] = array(
    'title'         => t('Cricket Scoreboard'),
    'page callback' => 'cricket_score_table',
    'page arguments' => array(1),
    'access arguments' => array('administer users'),
    'access callback' => TRUE,  
    'type' => MENU_LOCAL_TASK,
    'file' => 'cricketscore.inc',
    'weight' => 2   
);  
$items['abc/play/soccer_score'] = array(
    'title'         => t('Soccer Scoreboard'),
    'page callback' => 'soccer_score_table',
    'page arguments' => array(1),
    'access arguments' => array('administer users'),
    'access callback' => TRUE,  
    'type' => MENU_LOCAL_TASK,
    'file' => 'soccerscore.inc',
    'weight' => 1   
);

Now it shows both tabs after login, I want to show only one tab as per format. I go to scoreentry page, where I get the format code and I want to hide the tab based on that format.

1

Have a look at the Tab Tamer Module.

0

If you want to avoid showing both tabs simultaneously then you will need to manage path hierarchy. In a path hierarchy if sibling items are typo of MENU_LOCAL_TASK then they always appear in tabs simultaneously.

This is an example to break you path hierarchy in more deeper way.

$items['abc/play'] = array(
    'title' => t('Welcome Player'),
    'page callback' => 'drupal_get_form',
    'page arguments' => array('score_entry_table'),
    'file' => 'scoreentry.inc',
    'type' => MENU_NORMAL_ITEM,
);

$items['abc/play/cricket'] = array(
    'title' => t('Welcome Player'),
    'page callback' => 'drupal_get_form',
    'page arguments' => array('score_entry_table'),
    'file' => 'scoreentry.inc',
    'type' => MENU_NORMAL_ITEM,
);

$items['abc/play/soccer'] = array(
    'title' => t('Welcome Player'),
    'page callback' => 'drupal_get_form',
    'page arguments' => array('score_entry_table'),
    'file' => 'scoreentry.inc',
    'type' => MENU_NORMAL_ITEM,
);

$items['abc/play/cricket/score'] = array(
    'title'         => t('Cricket Scoreboard'),
    'page callback' => 'cricket_score_table',
    'page arguments' => array(1),
    'access arguments' => array('administer users'),
    'type' => MENU_LOCAL_TASK,
    'file' => 'cricketscore.inc',
);  

$items['abc/play/soccer/score'] = array(
    'title'         => t('Soccer Scoreboard'),
    'page callback' => 'soccer_score_table',
    'page arguments' => array(1),
    'access arguments' => array('administer users'),
    'type' => MENU_LOCAL_TASK,
    'file' => 'soccerscore.inc',

);

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.