Forums / Setup & design / Call main template variables in override templates

Call main template variables in override templates

Author Message

Ted Striker

Saturday 27 September 2008 12:24:42 pm

Hi,

I have several variables set in the main pagelayout.tpl template which I use several time in other templates, override and included templates. Whenerver I use them again I have to check database again for data, the same data.

Is there anyway to set this variables on the main template and them call them from withing other included and override templates? I tried $#var kind of call but it does not work.

Thanks!

Can you feel it Mr. Anderson? Closing in on you? Oh I can, I really should thank you after all. It was, after all, it was your life that taught me the purpose of all life. Purpose of life is to end.

Greg McAvoy-Jensen

Sunday 28 September 2008 8:19:51 am

Just a partial answer: I think $module_result (with main content area templates) is built before pagelayout.tpl is run, so I don't think it's possible to pass variables from pagelayout.tpl to a main content area template. The reverse is possible, though.

Granite Horizon, Certified Developer of eZ Publish Web Solutions
Provider of the SaaS Solution Granite Horizon In The Cloud | http://granitehorizon.com/cloud
http://granitehorizon.com | +1 916 647 6350 | California USA | @granitegreg
Blog: http://granitehorizon.com/blog

Gaetano Giunta

Sunday 28 September 2008 12:56:04 pm

Any variable that is defined in the pagelayout.tpl template is automatically available in all templates that are included subsequently from within the pagelayout itself (and cascading ones).
eg:

{def $myvar="yes"}
{include uri="design/mytemplate.tpl"}{* myvar will be available in mytemplate*}

As Greg correctly stated, these variables will not be available in the node template, and all templates included by the node template.
The reason is twofold:
- the node template is actually executed before the pagelayout template, within one html page
- the node template is not actually executed on every page view when the view cache is activated (which it should), but is only executed once every time the node content has been published

To ease passing variables from the node template to the pagelayout template, you can use the "persistent variable" mechanism. It works even with view cache on. Look it up on the docs / in the forum for more info.

Principal Consultant International Business
Member of the Community Project Board

Ted Striker

Monday 29 September 2008 2:23:52 pm

Unfortunately that seems to be what I need: passing the variable from pagelayout.tpl to node resultig templates.

Something that, if $node_result.content is executed in first place, doesn't seem to be possible. I guess I will have to recall the database search anytime I need this data.

Thank you for the answers!

Can you feel it Mr. Anderson? Closing in on you? Oh I can, I really should thank you after all. It was, after all, it was your life that taught me the purpose of all life. Purpose of life is to end.

eZ debug

Timing: Jan 18 2025 11:03:11
Script start
Timing: Jan 18 2025 11:03:11
Module start 'content'
Timing: Jan 18 2025 11:03:11
Module end 'content'
Timing: Jan 18 2025 11:03:12
Script end

Main resources:

Total runtime0.1961 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.0112 587.8594180.8125
Module start 'content' 0.01120.0060 768.671998.0547
Module end 'content' 0.01720.1789 866.7266526.3750
Script end 0.1961  1,393.1016 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00381.9172200.0002
Check MTime0.00150.7712200.0001
Mysql Total
Database connection0.00351.793510.0035
Mysqli_queries0.142672.71521410.0010
Looping result0.00150.77441390.0000
Template Total0.178591.010.1785
Template load0.00090.447710.0009
Template processing0.177690.534210.1776
Override
Cache load0.00060.306910.0006
Sytem overhead
Fetch class attribute can translate value0.00100.517410.0010
XML
Image XML parsing0.00030.160610.0003
General
dbfile0.00301.5272200.0001
String conversion0.00000.005130.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