{ 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.

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 30 2025 21:16:04
Script start
Timing: Jan 30 2025 21:16:04
Module start 'layout'
Timing: Jan 30 2025 21:16:04
Module start 'content'
Timing: Jan 30 2025 21:16:05
Module end 'content'
Timing: Jan 30 2025 21:16:05
Script end

Main resources:

Total runtime1.1885 sec
Peak memory usage8,192.0000 KB
Database Queries68

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0050 588.2578151.2266
Module start 'layout' 0.00500.0032 739.4844220.7188
Module start 'content' 0.00821.1794 960.20314,523.2734
Module end 'content' 1.18760.0008 5,483.476615.8125
Script end 1.1884  5,499.2891 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00340.2843160.0002
Check MTime0.00130.1064160.0001
Mysql Total
Database connection0.00080.063710.0008
Mysqli_queries1.082791.0970680.0159
Looping result0.00070.0618660.0000
Template Total1.134295.420.5671
Template load0.00220.181120.0011
Template processing1.132095.248420.5660
Template load and register function0.00190.159410.0019
states
state_id_array0.00130.111610.0013
state_identifier_array0.00270.223220.0013
Override
Cache load0.00200.1656730.0000
Sytem overhead
Fetch class attribute can translate value0.00170.145730.0006
Fetch class attribute name0.00270.223370.0004
XML
Image XML parsing0.00230.191330.0008
class_abstraction
Instantiating content class attribute0.00000.002180.0000
General
dbfile0.00220.1835170.0001
String conversion0.00000.000440.0000
Note: percentages do not add up to 100% because some accumulators overlap

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
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 43
 Number of unique templates used: 6

Time used to render debug report: 0.0001 secs