[support] Need help regarding hook_menu in drupal 6
pinky
pinky at evakoss.com
Fri Sep 19 07:08:32 UTC 2008
Thanks for the reply
Yes it is ok with this but I have some menu items like
<?php
$tid = get_tid( arg(0) );
if ($tid && arg(1) == '') {
$items[] = array(
'path' => arg(0),
'title' => t('List'),
'callback' => 'node_list',
'callback arguments' => array('new','old',arg(0) ),
'access' => TRUE,
'type' => MENU_CALLBACK_ITEM);
}
?>
I can't handle it this way. For this I defined my own wildcard loader
(http://drupal.org/node/209056) like
<?php
$items['%my_loader'] = array(
'title' => t('List'),
'callback' => 'node_list',
'callback arguments' => array('new','old',0),
'access' => TRUE,
'type' => MENU_CALLBACK_ITEM
);
function my_loader_load($text) {
if(is_tid($text)){
return $text;
}
else {
return FALSE;
}
}
?>
But this is also not working :-(
Pinky
-----Original Message-----
From: support-bounces at drupal.org [mailto:support-bounces at drupal.org] On
Behalf Of Jonathan Hedstrom
Sent: Thursday, September 18, 2008 10:31 PM
To: support at drupal.org
Subject: Re: [support] Need help regarding hook_menu in drupal 6
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
More information about the support
mailing list