[support] Need help regarding hook_menu in drupal 6

Jonathan Hedstrom jhedstrom at opensourcery.com
Thu Sep 18 17:00:55 UTC 2008



pinky wrote:
>
> Hi All!
>
> i am converting a drupal 5 module to drupal 6 module. i know
> 'hook_menu' is different here in drupal6
>
> *my menu item for drupal5 *
>
> if(arg(0) == 'published' || arg(0) == 'upcoming' || arg(0) == 'archived'){
>
> $items[] = array(
> 'path' => arg(0),
> 'title' => t('View'),
> 'callback' => 'node_list',
> 'callback arguments' => array(arg(0)),
> 'access' => TRUE,
> 'type' => MENU_CALLBACK_ITEM);
> }
>
> *i have changed this to *
>
> if (arg(0) == 'published' || arg(0) == 'upcoming' || arg(0) ==
> 'archived') {
> $items['%'] = array(
> 'title' => t('View'),
> 'page callback' => 'node_list',
> 'page arguments' => array(0),
> 'access callback' => TRUE,
> 'type' => MENU_CALLBACK_ITEM,
> );
> }
>
> please tell where i am doing wrong ??
>
What you have there won't work, since the menu is cached, not called
dynamically. Something like this would be a start:

$items['published'] = array(
  ...
);

$items['upcoming'] = array(
  ...
);

$items['archived'] = array(
  ...
);

See http://drupal.org/node/102338 for all the details.

Cheers,

Jonathan

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: OpenPGP digital signature
Url : http://lists.drupal.org/pipermail/support/attachments/20080918/e438ed50/attachment.pgp 


More information about the support mailing list