This site has been archived and you can no longer log in or post new messages. For up-to-date community resources please visit ezplatform.com

eZ Community » Forums » Install & configuration » How Can I access URI parameters in...
expandshrink

How Can I access URI parameters in templates?

How Can I access URI parameters in templates?

Wednesday 22 January 2003 10:03:43 am - 8 replies

I've created a new "ViewMode" and his URI has two new parameters (i.e.: content/view/frontpage/16//param1/param2)

I need access to parameters in .../templates/node/view/frontpage.tpl but $viewParameters only has "ViewMode", "NodeID" and "LanguageCode".

Where are "param1" and "param2"?

Thanks in advance
Adolfo Barragan

Wednesday 22 January 2003 12:46:53 pm

> I've created a new "ViewMode" and his URI has two new
> parameters (i.e.:
> content/view/frontpage/16//param1/param2)
>
> I need access to parameters in
> .../templates/node/view/frontpage.tpl but $viewParameters
> only has "ViewMode", "NodeID" and "LanguageCode".
>
> Where are "param1" and "param2"?
>
> Thanks in advance
> Adolfo Barragan

Sorry, don't have an answer to this. But your approach sounds interesting. Would you like to share how you created the custom view mode? I am sure, that it's not too difficult and that other users can benefit from this.

I prepared a Wiki site. You just have to add a few sentences of description. happy.gif Emoticon

http://ezwiki.blanko.info/index.php/3XHT_NewViewMode

Thanks in advance.
Karsten

Thursday 23 January 2003 8:45:26 pm

Hello!
You should try to extract all params with code like this:
$Module =& $Params["Module"];
$viewParams = $Module->ViewParameters;

$viewParams is now an array contained all parameters
now you only have to hand over the array or extracted fields to your .tpl file with "setAttribute" function.
Hope this will help.

Friday 24 January 2003 6:20:02 pm

> Hello!
> You should try to extract all params with code like this:
> $Module =& $Params["Module"];
> $viewParams = $Module->ViewParameters;
>
> $viewParams is now an array contained all parameters
> now you only have to hand over the array or extracted fields
> to your .tpl file with "setAttribute" function.
> Hope this will help.

I try this, but $viewParams has only the "oficial" parameters, i.e: "ViewMode", "NodeId" and "LanguageCode".

Can you show me an example of "setAttribute" function?

Thanks
Adolfo Barragán

Friday 24 January 2003 6:47:37 pm

> > I've created a new "ViewMode" and his URI has two new
> > parameters (i.e.:
> > content/view/frontpage/16//param1/param2)
> > ...

> I prepared a Wiki site. You just have to add a few sentences
> of description. happy.gif Emoticon
>
> http://ezwiki.blanko.info/index.php/3XHT_NewViewMode
>
> Thanks in advance.
> Karsten

I try your link, but I need login. I searh in pages and follow "sign in" but I received an error.

If you wish you can speak me at fatimamc@supercable.es

Regards
Adolfo Barragán

Friday 24 January 2003 8:27:44 pm

Hi again!
Have you tried to modify line 75 in your /kernel/content/module.php file?
Try adding these new parameters to an array under key "params".
Bye and good luck

Friday 24 January 2003 8:28:40 pm

Hi again!
Have you tried to modify line 75 in your /kernel/content/module.php file?
Try adding these new parameters to an array under key "params".
Of course if you created new view then you should modify suitable module.php file.
Bye and good luck

Saturday 25 January 2003 7:32:07 am

> Hi again!
> Have you tried to modify line 75 in your
> /kernel/content/module.php file?
> Try adding these new parameters to an array under key
> "params".

I made something similar but I don't sure what is the best solution.

I've modified kernel/content/view.php:
I've added a new variable $myParams = $Params['Parameters'] (around line 53), and (around line 150) I've added $tpl->setVariable( 'myParams', $myParams ).

Now, I have a cariable $myParams in my new template.

What do you think?

P.S.: Can do you see message http://developer.ez.no/forum/message/13750 ?

Thanks in advanced
Adolfo Barragán

Sunday 26 January 2003 12:23:06 am

I think it's a good solution but I found better and more formal. Try to modify line 75 in /kernel/content/module.php:
"params" => array( "ViewMode", "NodeID", "LanguageCode", "Param1", "Param2" ),
now in /kernel/content/view.php you can access params from URI (eg. index.php/user/content/view/full/2//Hello/World) with $Params['Param1'] and $Params['Param2'].

As for the second problem I found out how to access
multidimensional array and I succeed only with sth like that:
assume you hand over to your tpl file array:
$ar = array ( array ( array("0"=>"day_num", "1"=>"object_id"blunk.gif Emoticon ) );
to access your "object_id" param you need to write:
{let ar_0=$ar.0}{let ar_0_0=$ar_0.0}{let ar_0_0_1=$ar_0_0.1}
This is rather rare way to access array field, but I think you can now build loops taking advantage of the code I've written.

Take care,
Pawel Frukacz

expandshrink

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from