[development] url as callback argument

Jakob Petsovits jpetso at gmx.at
Tue Feb 3 23:32:37 UTC 2009


On Tuesday 03 February 2009, Iñaki Lopez wrote:
> $items[] = array(
>    'path' => 'admin/settings/featured-comments/feature',
>    'title' => t('featured comment'),
>    'callback' => 'feature_comment',
>    'callback_args' => $_GET['cid'],
>
> should be..
>
> $items[] = array(
>    'path' => 'admin/settings/featured-comments/feature/%',
>    'title' => t('featured comment'),
>    'callback' => 'feature_comment',
>    'callback_args' =>array(4),
> ...

Bad advice:

1. There is no '%' wildcard in Drupal 5, and Drupal 6 puts the path as array 
key instead of having a separate 'path' element.

2. There is no 'callback_args' property. array(...) is correct, but it also 
needs to be renamed to 'callback arguments' for Drupal to do anything with it.
In Drupal 5, that would be "'callback arguments' => array($_GET['cid'])".
(Or 'page callback' and 'page arguments' in Drupal 6, which I understand the 
original poster is not using at this time.)

Maybe the thread is better off dead - 
http://api.drupal.org/api/function/hook_menu/5 has been posted already -
but it's hard to leave the above example uncommented as is.

Cheers,
  j



More information about the development mailing list