By default every node should have the menu tab (MENU LOCAL TASK) of View and Edit.
If your module wants to add its own tab but only restricted to content type of "foo", then use the following code snippet.
XYZ below is your page callback for the new custom tab. Basically it calls another function to validate user's permission but we manipulate it to check the node type (via access callback).
/**
* Implements hook_menu().
*/
function YOUR_MODULE_menu() {
$items = array();
$items['node/%node/XYZ'] = array(
...
'access callback' => 'YOUR_MODULE_access_check',
'access arguments' => array(1),
'type' => MENU_LOCAL_TASK,
);
return $items;
}
function YOUR_MODULE_access_check($node) {
if ($node->type == 'foo') {
return TRUE;
}
return FALSE;
}
Remember to clear your Drupal caches at admin/config/development/performance after every change to your hook_menu above.
Read more about hook_menu() here.
Sorry, I don't know of easier way to explain this, let me know if you don't understand.
We did understand
Indeed it was not easy to explain but i think we all did understand your post. Thanks!
Alex
Add new comment