[drupal-devel] param in middle of url?
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
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
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
Hi,
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?
Well, the easiest way to get your answer is to look at how user.module does this (user_menu()). Goba
Perfect.. Thanks to everyone who responded. :) -+Aaron Gabor Hojtsy wrote:
Hi,
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?
Well, the easiest way to get your answer is to look at how user.module does this (user_menu()).
Goba
participants (4)
-
Aaron Stewart -
Fabiano Sant'Ana -
Gabor Hojtsy -
Moshe Weitzman