Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By ravi_drupal on
Hi,
I want to pass query string parameter to drupal modules from web browser directly.
i.e i want to access http://localhost/drupal/?q=admin/build/services/browse/user.get?uid=1 but it shows me message as "Page not found.The requested page could not be found.".
How can i pass the query string parameter to drupal module??
Thanks,
Ravi.
Comments
Hi, It's a bit unclear for
Hi,
It's a bit unclear for me what you want to do, but I can tell you a fact: the url is not a valid one. You cannot have two "?" in a url. So, a valid one should be like this: http://localhost/drupal/?q=admin/build/services/browse/user.get&uid=1.
In your callback function that is responsible for this request, you can get the "uid" value from the url via $_GET.
Can you paste here the code snippet where you construct the url?, and maybe I can help you....
Vasi.
How to pass query string parameter to modules in drupal from URL
Hi Vasi,
Thanks for your quick reply.Sorry for unclear post as i am System programmer and new to web development.
I am trying to get response for the http://localhost/drupal/?q=admin/build/services/browse/user.get&uid=1 . Right now trying by pasting the URL directly into browser.
My final goal is to call services from iPhone and i want to get response generated on iPhone side.
Please let me know if you have any ideas on this.
Thanks,
Ravi.
You will want to use
You will want to use hook_menu() to register a URL at admin/build/services/browse/user.get/%
The % is a wildcard. You can pass it any value you want, then use the 'page arguments' element of the array you use to register your URL to pass the value to the page callback function.
i will try with this
Hello Jay,
Thanks for your replay.
I will definitely try with this.
Ravi.
did it work?
did the suggestion work?
my url is: localhost/myauto/?q=sometext
But the following code does not work!!
mymodule_menu(){
$items['myauto/%'] = array(
'title'= 'My example',
'page callback' => 'myexample_auto',
'page argument' => array('1'),
'access callback' => TRUE,
);
myexample_auto($arg){
...//user $_GET['q'] or drupal_get_query_parameters to get 'sometext' from $arg
}
...//user $_GET['q'] or
You should have this:
Also note that you should not be using q=, as 'q' is what Drupal uses by default (in the background) and you'll mess things up.
Try $_REQUEST['destination']
Try
Say thanks.