Forums / Install & configuration / { let.. and { default... - What's the diffrence?

{ let.. and { default... - What's the diffrence?

Author Message

Alexei Pechekhonov

Wednesday 08 January 2003 6:40:07 am

Does somebody know (or can explaine me ) the difference of two statements in template files for variables settings?
You may recognize { default ... } <class_tpl_content>{/default} in every class tpl. Please, what does it make difference {let statement (for section tpls) and {default statement (for both, section and class tpls)?
Alexei

Jan Borsodi

Thursday 09 January 2003 1:56:24 am

> Does somebody know (or can explaine me ) the difference of
> two statements in template files for variables settings?
> You may recognize { default ... }
> <class_tpl_content>{/default} in every class tpl. Please,
> what does it make difference {let statement (for section
> tpls) and {default statement (for both, section and class
> tpls)?

let and default are almost the same thing in that they only set a variable if it does not already exist. However let will issue an error if the variable exists and default will not.

default is often used in included templates where you might have default values which are most used but which may be overridden by the including template.

Example:

mytemplate.tpl:
{default size=5}
size={$size}
{/default}

main.tpl:
{include uri='mytemplate.tpl'}
{include size=10 uri='mytemplate.tpl'}

--
Amos

Documentation: http://ez.no/ez_publish/documentation
FAQ: http://ez.no/ez_publish/documentation/faq

sergey podlesnyi

Monday 27 January 2003 9:04:38 am

Is it possible to modify values of variables? E.g.

{let i=1}
{section loop=10}
{let i=sum($i,1)}
{/section}

or just

{let x=10}
{let x=$x + 20}

sergey podlesnyi

Monday 27 January 2003 9:39:25 am

Is it possible to modify values of variables? E.g.

{let i=1}
{section loop=10}
{let i=sum($i,1)}
{/section}

or just

{let x=10}
{let x=$x + 20}

Jan Borsodi

Monday 27 January 2003 12:23:43 pm

> Is it possible to modify values of variables? E.g.
>
> {let i=1}
> {section loop=10}
> {let i=sum($i,1)}
> {/section}

Yes, however you need to use set to modify existing variables.
{let i=1}
{section loop=10}
{set i=sum($i,1)}
{/section}
{/let}

You also need an ending let which will unset the variable (same with default).

> or just
>
> {let x=10}
> {let x=$x + 20}

The template engine does not have specialized arithmetic operators built in like other engines, instead it relies on custom template to do the work.
The template behaves much like LISP (Used in Emacs for instance), ie. the operator is written before the operands.

x=1+2+3+4+5+6
{set x=sum(1,2,3,4,5,6)}

y=a*x+b
{set y=sum(mul($a,$x),$b)}

{set a=sum(and($b,$c,$d),or($e,$f,$g))}
The and will return $d if all input are "true" and the or will return the first that is "true".

--
Amos

Documentation: http://ez.no/ez_publish/documentation
FAQ: http://ez.no/ez_publish/documentation/faq

sergey podlesnyi

Tuesday 28 January 2003 12:11:36 am

Thanks a lot Jan! Your reply is absolutely comprehensive.

Sometimes I reply to newbies' questions here but this is your deep knowledge of EZ Publish that helps a lot to fill the gap until complete documentation is available.

eZ debug

Timing: Jan 18 2025 03:00:31
Script start
Timing: Jan 18 2025 03:00:31
Module start 'content'
Timing: Jan 18 2025 03:00:31
Module end 'content'
Timing: Jan 18 2025 03:00:31
Script end

Main resources:

Total runtime0.8500 sec
Peak memory usage4,096.0000 KB
Database Queries205

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0071 587.8359180.8203
Module start 'content' 0.00710.7158 768.6563620.9063
Module end 'content' 0.72290.1270 1,389.5625337.0781
Script end 0.8499  1,726.6406 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00410.4805210.0002
Check MTime0.00160.1850210.0001
Mysql Total
Database connection0.00110.132210.0011
Mysqli_queries0.769290.49682050.0038
Looping result0.00200.24082030.0000
Template Total0.815595.920.4078
Template load0.00220.262420.0011
Template processing0.813395.678620.4066
Template load and register function0.00020.020510.0002
states
state_id_array0.00090.105510.0009
state_identifier_array0.00110.132120.0006
Override
Cache load0.00200.2321730.0000
Sytem overhead
Fetch class attribute can translate value0.00140.160140.0003
Fetch class attribute name0.00190.226170.0003
XML
Image XML parsing0.00100.112840.0002
class_abstraction
Instantiating content class attribute0.00000.001580.0000
General
dbfile0.00350.4128280.0001
String conversion0.00000.000830.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
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
6content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
15content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
18content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
2content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 43
 Number of unique templates used: 6

Time used to render debug report: 0.0002 secs