[drupal-devel] param in middle of url?

Moshe Weitzman weitzman at tejasa.com
Sat Oct 1 16:23:38 UTC 2005


you can use 'callback arguments' feature of hook_menu() to make the 
callback function even cleaner ...

function example_menu($may_cache) {
$items[] = array('path'     => 'bar',
                   'title'    => t('example'),
                   'callback' => 'example_callback',
                   'access'   => user_access('access content'));
                   'callback arguments' = arg(1);

function example_callback($user_id) {


Fabiano Sant'Ana wrote:
> Yes,
> You can use "func_get_args();" or just declare your callback like this:
> 
> /**
> * Implementation of hook_menu().
> */
> function example_menu($may_cache) {
> $items = array();
> $items[] = array('path'     => 'bar',
>                  'title'    => t('example'),
>                  'callback' => 'example_callback',
>                  'access'   => user_access('access content'));
> return $items;
> }
> 
> function example_callback($user_id,$bar) {
> ...
> }
> 
> cheers,
> Fabiano Sant'Ana
> 
> Aaron Stewart escreveu:
> 
>> Hey all..
>>
>> I want to do something like this:
>>
>> ?q=foo/1/bar
>>
>> where "1" in this case is a user id (or rather, I want it to be a param
>> into my callback).
>>
>> Is there a facility that already exists for doing this?
>>
>> Thanks,
>> -=Aaron
>>  
>>
> 




More information about the drupal-devel mailing list