[development] MENU_LOCAL_TASK for just some node types

Lluís enboig at gmail.com
Fri Jun 6 08:26:04 UTC 2008


not prefectly; I have observed an odd behaviour with my function: it
just works the first time I change the path ("pressupostos" by
something else); as soon as I clear the cache (using devel module) the
tab disappear.

function comptacau_project_menu() {
  global $node;
  $items=array();

  if ($may_cache) {
    $items[] = array('path' => 'comptacau/projects_autocomplete',
                     'title' => t('project_autocomplete'),
                     'callback' => 'projects_autocomplete',
                     'access' => comptacau_access('search_project'),
                     'type' => MENU_CALLBACK);
  }
  else {  //no cache
    if (arg(1)>0) {  //just load the node when there is a node
      $node = node_load(arg(1));
    }
    $items[] = array('path' => 'node/'. arg(1) .'/pressupostos',  //if
I change this line, the tab appear
                     'title' => t('Pressupost'),
                     'callback' => 'drupal_get_form',
                     'callback arguments' =>
array('comtpacau_project_pressupost_form',arg(1)),
                     'access' => ($node->type=='comptacau_project'),
                     'type' => MENU_LOCAL_TASK);
  }
  return $items;
}

What am I missing?

thanks a lot

On Thu, Jun 5, 2008 at 5:30 PM, Lluís <enboig at gmail.com> wrote:
> It works prefectly, thanks a lot.
>
> On Thu, Jun 5, 2008 at 5:02 PM, Saint-Genest Gwenael
> <gwenael.saint-genest at makina-corpus.com> wrote:
>> 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
>>
>
>
>
> --
> *La felicitat ha de ser compatible, compartible i cooperativa.
> *Envellim quan els records superen les esperances.
> *Als llocs desconeguts només s'hi arriba per camins desconeguts.
> *Abans d'imprimir aquest missatge, pensa en el medi ambient.
>



-- 
*La felicitat ha de ser compatible, compartible i cooperativa.
*Envellim quan els records superen les esperances.
*Als llocs desconeguts només s'hi arriba per camins desconeguts.
*Abans d'imprimir aquest missatge, pensa en el medi ambient.


More information about the development mailing list