1

I am using the following code to include a custom tab for my node types:

function mymodule_menu(){
    $items['node/%node/register']   =   array(
        'page arguments' => array(1),
        'access arguments'  =>  array('access content'),
        'type'  =>  MENU_LOCAL_TASK,
        'title' =>  'Register',
    );
    return $items;
}

This has the effect of including a register tab for every node type. However, I need to include that tab for only page types and exclude it on all other type like article types etc.

What other directions can I consider?

halfer
  • 19,824
  • 17
  • 99
  • 186
sisko
  • 9,604
  • 20
  • 67
  • 139

1 Answers1

0

The easiest way would be to provide your own access callback that checks the node type, e.g.

function mymodule_menu(){
  $items['node/%node/register'] = array(
    'page arguments' => array(1),
    'access callback' => 'mymodule_node_register_tab_access',
    'access arguments' => array(1),
    'type'  =>  MENU_LOCAL_TASK,
    'title' =>  'Register',
  );
  return $items;
}

function mymodule_node_register_tab_access($node) {
  $valid_types = array('page');
  return in_array($node->type, $valid_types);
}
Clive
  • 36,918
  • 8
  • 87
  • 113