I developped my own module to produce an odt version of a node. For this I added a new tab on each node with the hook_menu() like this :
function node_to_odt_menu() {
...
$items['node/%node/node_to_odt'] = array(
'access callback' => 'node_to_odt_access',
'access arguments' => array(1),
'page callback' => 'node_to_odt_node_to_odt',
'page arguments' => array(1),
'title' => 'Odt version',
'weight' => 5,
'type' => MENU_LOCAL_TASK,
);
...
}
function node_to_odt_access ($node) {
global $user;
// Check basic permissions first.
$access = (user_access('export node to odt') );
// Make sure the user can view the original node content.
$access = $access && node_access('view', $node);
// Check additional conditions
$access = $access && (node_to_odt_is_permitted($node->type) && filter_access($node->format) );
// Let other modules alter this - for exmple to only allow some users
// to export specific nodes or types.
drupal_alter("node_to_odt_access", $access, $node);
return $access;
}
This tabs is correctly shown when I go to a node.
Now I want to add a new tabs when the node is a book parent, to produce an odt version for a book. So I added a new part in hook_menu() of my module and a new access function like this :
function node_to_odt_menu() {
...
$items['node/%node/book_node_to_odt'] = array(
'access callback' => '_book_node_to_odt_access',
'access arguments' => array(1),
'page callback' => 'book_node_to_odt',
'page arguments' => array(1),
'title' => 'Book Odt version',
'weight' => 5,
'type' => MENU_LOCAL_TASK,
);
..
}
function _book_node_to_odt_access ($node) {
//same as node_to_odt_access for the moment
}
The problem is that the new tab is not shown.
So I tried another method : have only one access function (node_to_odt_access) whith 2 arguments :
function node_to_odt_menu() {
$items['node/%node/node_to_odt'] = array(
'access callback' => 'node_to_odt_access',
'access arguments' => array('node',1),
'page callback' => 'node_to_odt_node_to_odt',
'page arguments' => array(1),
'title' => 'Odt version',
'weight' => 5,
'type' => MENU_LOCAL_TASK,
);
$items['node/%node/book_node_to_odt'] = array(
'access callback' => 'node_to_odt_access',
'access arguments' => array('book',1),
'page callback' => 'book_node_to_odt',
'page arguments' => array(1),
'title' => 'Book Odt version',
'weight' => 5,
'type' => MENU_LOCAL_TASK,
);
}
function node_to_odt_access ($type,$node) {
...
}
But when I made this I had a warning : "warning: Missing argument 2 for node_to_odt_access() ".
How can I had this second tab ?
Comments
Did you try clearing the menu
Did you try clearing the menu cache?
Clear the cache was the solution !
When I clear the cache in menu Performance, my second tab appears !
thanks !