Forums / Developer / HTTP-Request to call on a module and pass a parameter
Daniel Scheiner
Friday 06 October 2006 7:40:25 am
Hi!
I need to dynamicly create a URL that is structured like so:
www.testing.com/mymodule/parameter or www.testing.com/mymodule?=parameter (or some variation of that)(eventually more than one parameter)
I need a HTTP-Request made to that URL to call up a module and give it said parameter.Later i will have to use the parameter.
How can I do that?THANKS!!!
Sascha Frinken
Friday 06 October 2006 7:53:37 am
Hope I didn't get You wrong...
I would (as always) write a template operator for it.
Within the template operator you could use wget, curl or fsockopen.
HTH
Sascha
Claudia Kosny
Friday 06 October 2006 8:14:24 am
Hi Daniel
Have a look at the way EZ manages system urlshttp://ez.no/doc/ez_publish/technical_manual/3_8/concepts_and_basics/url_translation
and custom view parametershttp://ez.no/doc/ez_publish/technical_manual/3_8/concepts_and_basics/modules_and_views
Greetings fromLuxembourg
Claudia
Friday 06 October 2006 10:03:48 am
hmmm... maybe i should explain a little better:
the url that i need will differ every time.
www.test.com/whatever/parameter1
this "parameter1" that is in the url must be passed on to the module (!!!) and will be used there. and in addition to that i need the module to accept http-post-request variables.
is that possible and if so, i really would love to know how... like in a example (sorry.... i'm not yet as adapt in ezp)
thanks!!!
Friday 06 October 2006 10:46:30 am
Unless I understand you totally wrong this is exactly what view parameters are doing. The only problem might be that you would have a view in your url, something like this:www.testing.com/mymodule/myview/parameter
Your view (which the module.php maps to an script) has access to $Params which contains the parameters. To have ordered parameters you need to specify their name(s) in the module.php in your extension. Example:$ViewList["main"] = array('script' => 'main.php', 'params' => array('rootNodeID'));
So I could call up the view main of my extension myextension like this:www.example.com/index.php/myextension/main/42
Here the view main calls up a script main.php which can access the passed value 42 by using $Params['rootNodeID']. The script main is a normal php file which is then responsible for calling a template or forwarding to another view.
To access post variables you could use plain $_POST or, using the EZ tools:
include_once( "lib/ezutils/classes/ezhttptool.php" ); $http =& eZHTTPTool::instance(); else if ( $http->hasPostVariable( "foo" ) ) { $foo= $http->postVariable( "foo); }
Greetings from Luxembourg