Section (legacy)
This page is for designers who maintain older templates. {section} was the general-purpose loop and condition of
early template versions; it still works (eZTemplateSectionFunction) and still appears in shipped templates. New
templates use {foreach}, {if} and {def}.
Contents
Reading it
section name=Child loop=$children
<li>$Child:item.name|wash</li>
section-else
<li>'None'|i18n( 'design/mytheme' )</li>
/sectionloop=the array (or a number: loop that many times).name=a namespace; inside, the current item is$Child:item, the key$Child:key, the index$Child:index.section-elseruns when the array is empty.show=makes the section a condition:{section show=$node.can_edit} ... {/section}.sequence=,max=,offset=,{delimiter}work like their foreach counterparts.
Converting it
| Section | Modern |
|---|---|
{section name=X loop=$list} ... $X:item | {foreach $list as $item} ... $item |
{section-else} | {if $list|count}{foreach ...}{/foreach}{else}...{/if} |
{section show=$cond} | {if $cond} |
{let a=1} ... {/let} | {def $a=1} ... {undef $a} |
$:item (current namespace) | the loop variable |
Convert a template completely, then compare the output of a few pages before and after.
Related pages
- Foreach loops
- If and conditions
- Free documentation: this page is free to copy, translate and improve under the GNU FDL 1.3.
Become an Exponential Partner
Partners share their information, provide funding, contribute back and develop the products with us, and that is how Exponential grows. A partner website and dashboard are planned for mid-2027: please become a partner today to speed up our growth rate and land new features faster.