Forums / Install & configuration / How Can I access URI parameters in templates?

How Can I access URI parameters in templates?

Author Message

Adolfo Barragán

Wednesday 22 January 2003 1:03:43 am

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

Karsten Jennissen

Wednesday 22 January 2003 3:46:53 am

> 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. :-)

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

Thanks in advance.
Karsten

Pawel Frukacz

Thursday 23 January 2003 11:45:26 am

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.

Adolfo Barragán

Friday 24 January 2003 9:20:02 am

> 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

Adolfo Barragán

Friday 24 January 2003 9:47:37 am

> > 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. :-)
>
> 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

Pawel Frukacz

Friday 24 January 2003 11:27:44 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".
Bye and good luck

Pawel Frukacz

Friday 24 January 2003 11:28:40 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".
Of course if you created new view then you should modify suitable module.php file.
Bye and good luck

Adolfo Barragán

Friday 24 January 2003 10:32:07 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".

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

Pawel Frukacz

Saturday 25 January 2003 3:23:06 pm

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") ) );
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

eZ debug

Timing: Jan 30 2025 00:45:56
Script start
Timing: Jan 30 2025 00:45:56
Module start 'content'
Timing: Jan 30 2025 00:45:56
Module end 'content'
Timing: Jan 30 2025 00:45:56
Script end

Main resources:

Total runtime0.2125 sec
Peak memory usage2,048.0000 KB
Database Queries141

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0074 588.1797180.8047
Module start 'content' 0.00740.0043 768.9844101.8672
Module end 'content' 0.01170.2007 870.8516530.2500
Script end 0.2124  1,401.1016 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00331.5564200.0002
Check MTime0.00140.6488200.0001
Mysql Total
Database connection0.00080.380810.0008
Mysqli_queries0.165978.09501410.0012
Looping result0.00130.59911390.0000
Template Total0.200494.310.2004
Template load0.00070.345510.0007
Template processing0.199793.993610.1997
Override
Cache load0.00050.240110.0005
Sytem overhead
Fetch class attribute can translate value0.00060.272010.0006
XML
Image XML parsing0.00020.104010.0002
General
dbfile0.00833.9058200.0004
String conversion0.00000.003330.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs