And another Drupal tip for today: "How to add a tab to the node in Drupal":
Put this snippet in hook_menu of your new module:
$items['node/%node/new_tab'] = array(
'title' => 'New Tab',
'page callback' => 'mycallback',
'page arguments' => array(1),
'access callback' => TRUE,
'type' => MENU_LOCAL_TASK
)
This tab is going to be shown on any node type and without access restrictions,
however, if you need to specify a special node type, 'custom_node' for example, do the following:
put this snippet in hook_menu of your new module:
$items['node/%custom_node/new_tab'] = array(
'title' => 'New Tab',
'page callback' => 'mycallback',
'page arguments' => array(1),
'access callback' => TRUE,
'type' => MENU_LOCAL_TASK
)
And create a function:
function custom_node_load($arg) {
$node = node_load($arg);
if($node->type == 'custom_node')
return $node;
return FALSE;
}
Hope this helps!
Posted in Web Development, February 11th, 2010
Tags: drupal
Post new comment