By wpanssi on
I am trying to create a module which adds a new tab for webform nodes. I used this as my starting point: http://drupal.org/node/307209
Here is my menu hook:
$items['node/%node/new_tab'] = array(
'title' => 'New Tab',
'page callback' => 'jmodify_webform_mycallback',
'page arguments' => array(1),
'access callback' => check_type(arg(1)),
'type' => MENU_LOCAL_TASK
);
return $items;
And here is function I use check if the current node is a webform.
function check_type($nid){
if(is_numeric($nid)) {
$node = node_load($nid);
if($node->type == 'webform')
return TRUE;
else
return FALSE;
}
return false;
}
The menu hook doesn't get called every time I reload the page so the access check does not take place. What am I missing here?
Comments
%node
One problem I see is that you are expecting the %node wildcard to return a node id. It does not. It calls the node_load($nid) function for you and returns the $node object as your argument. So your check_type function should look like this: