[development] MENU_LOCAL_TASK for just some node types

Saint-Genest Gwenael gwenael.saint-genest at makina-corpus.com
Thu Jun 5 15:02:37 UTC 2008


Hi,

   You can use node_load() to get node type attribute.

function comptacau_project_menu($may_cache) {
   $items=array();
   if (arg(0) == 'node' && is_numeric(arg(1))) {
       $node = node_load(arg(1));
       // DEBUG: Example with 'page' but can be anything else ...
       if ($node->type == 'page') {
         $items[] = array(
           'path' => 'node/'. arg(1) . '/pressupost_form',
           'title' => t('Pressupost'),
           'callback' => 'devel_load_object',
           'callback arguments' => array($node),
           'access' => user_access('access devel information'),
           'type' => MENU_LOCAL_TASK
         );
       }
   }
   return $items;
}

G. Saint-Genest

-- 
Gwenael Saint-Genest
MAKINA CORPUS - www.makina-corpus.com
44 boulevard des Pas Enchantés FR-44230 Saint Sébastien sur Loire
Tel : +33 (0) 2 40 94 96 08


More information about the development mailing list