Drupal 7 hook_menu for specific content type

Viewed 6482

I tried to add a new tab to a specific content type 'abc', here is the code, but it doesn't work, the tab shows on all the nodes. Can anybody help with it? Thank you!

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

  $items['node/%node/test'] = array(
  'title' => 'Test',
  'page callback' => 'handle_test',
  'page arguments' => array('node', 1),
  'access arguments' => array('access content'), 
  'type' => MENU_LOCAL_TASK,
  'weight' => 100,
  );
return $items;
}

function handle_test($node){

  $result='hi';
  if ($node->type == 'abc') {
    $result='I am working';
}
1 Answers
Related