Forums / Developer / Impossible to pass params to templates?

Impossible to pass params to templates?

Author Message

Massimiliano Bariola

Thursday 23 June 2005 4:24:37 am

eZpublish 3.6.0 :

{include uri='design:pager.tpl' name = 'pager' view_parameters = $view_parameters foo = $myfoo}

in pager.tpl:

{$foo|attribute(show,1)}

debug says

Unknown template variable 'foo' in namespace '' .

This happens whether I put a namespace or not. Am I missing something?

Ɓukasz Serwatka

Thursday 23 June 2005 6:10:17 am

Hi,

Look at this document
http://ez.no/ez_publish/documentation/customization/custom_design/user_specified_parameters

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog

Massimiliano Bariola

Thursday 23 June 2005 7:16:31 am

Hi Lukasz,

That works, I have been trying it, because $view_parameters array is available within the template. but I really need to pass the values without filling the URI. in my case, I might have maybe 3 or 4 includes of that pager.tpl on the same page which need different parameters in each include. That would lead to extremely long and awkward URIs if I had to pass them all through the URI.

I really need to understand why parameter foo isn't passed to the templade via the include statement; maybe I am getting something wrong, but I can't find what. I have been browsing at google.tpl code, and I seem to pass/handle the parameters in the same way ... so I am rather puzzled.

Hans Melis

Thursday 23 June 2005 7:37:46 am

Hi,

The template with the {include} code; is it called with node_view_gui or one of the similar functions?

If so, the object forwarder functions (that's their name) always set a namespace.

Try {$:foo|attribute(show)} in pager.tpl to see if any namespaces are active ($: always refers to the current namespace).

Hans
http://blog.hansmelis.be

Massimiliano Bariola

Thursday 23 June 2005 8:09:28 am

Hi Hans,

I am not sure I understood you correctly. but no, the template does no attribute/node_view_gui within it. it is just plain HTML code output, switched and cycled through depending on the passed parameters.

in classifiche.tpl (a template of my custom extension, invoked from url www.mysite.com/wt/classifiche)

{def $myfoo = 'HELLO!'}
{include uri='design:pager.tpl' view_parameters = $view_parameters foo = $myfoo}

first lines of footer.tpl (for debugging purposes):

<h1>{$foo|attribute(show)}</h1>
<hr/>
<h1>{$:foo|attribute(show)}</h1>
both lines show me the familiar
"Attribute Type Value" line, but no content under it.

I don't get the error "Unknown template variable 'foo' in namespace '' " now (I don't know why I don't get the error now), but no content / value passing yet.

Hans Melis

Thursday 23 June 2005 8:57:46 am

Massimiliano,

The |attribute(show) is only useful if performed on an object or an array.

The example you posted declares $myFoo as the string <i>HELLO!</i>. Doing an attribute(show) on a simple type (boolean, string, int, float,...) only returns the "Attribute Type Value" line. If you want to see what's in those variables, you only need to print them, e.g. {$:foo}

Hans
http://blog.hansmelis.be

Massimiliano Bariola

Thursday 23 June 2005 9:10:38 am

Hans,

of course you're right! I think I have spent too much time in front of the pc today .. :)

I rerun the test, and I get a HELLO! for both $foo and $:foo .

So I am "happy". the quotation marks are due to the fact that I do not know why the "unknown variable" error disappeared by itself, so I cannot say I "grasped" it.

Still, thanks for your valuable help. Tomorrow I'll clean up the code and finally finish implementing the pager :)

eZ debug

Timing: Jan 20 2025 06:35:53
Script start
Timing: Jan 20 2025 06:35:53
Module start 'content'
Timing: Jan 20 2025 06:35:53
Module end 'content'
Timing: Jan 20 2025 06:35:53
Script end

Main resources:

Total runtime0.1279 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.0057 590.1875180.8281
Module start 'content' 0.00570.0050 771.0156101.8828
Module end 'content' 0.01070.1171 872.8984530.0781
Script end 0.1279  1,402.9766 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00352.7459200.0002
Check MTime0.00151.1813200.0001
Mysql Total
Database connection0.00090.683110.0009
Mysqli_queries0.088669.26451410.0006
Looping result0.00120.92041390.0000
Template Total0.116891.310.1168
Template load0.00110.877210.0011
Template processing0.115790.438910.1157
Override
Cache load0.00080.631710.0008
Sytem overhead
Fetch class attribute can translate value0.00060.444710.0006
XML
Image XML parsing0.00030.208010.0003
General
dbfile0.00201.5565200.0001
String conversion0.00000.004730.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.0002 secs