Forums / Developer / How to get my URL variables into my extension ?

How to get my URL variables into my extension ?

Author Message

Damien MARTIN

Friday 17 July 2009 6:54:48 am

Hi there,

I have a new problem :

I'm programming a new extension who have to get variables from URLs :

<mywebsite>/teleform/telecharger/(document)/125

So, I would like to get the "document" parameter from my PHP code.

I tried :

$http = new eZHTTPTool();
$http->variable("document");

But my object is still empty.

I searched around the API but I feel lost...

What is the class that handle this kind of datas ?

Thanks,

Damien

Gaetano Giunta

Friday 17 July 2009 7:25:22 am

You should declare your view variables in the module.php file.

In this case, it is a named var (as opposed to positional ones), so you should add something like this:
$ViewList = array(
'telecharger' => array(
// other stuff here...
'unordered_params' => array( 'document' => 'document' )

Then you recover them as
$document= (string) $Params['document'];

Principal Consultant International Business
Member of the Community Project Board

Damien MARTIN

Friday 17 July 2009 7:36:19 am

Thank you very much Gaetano, it works very well !

:)