Set-block and append-block
This page is for designers who need rendered markup in a variable instead of in the output.
Contents
set-block
Renders its body and stores the text in a variable (eZTemplateBlockFunction):
set-block variable=$share_bar
include uri='design:parts/share.tpl' node=$node
/set-block
<header>$share_bar</header>
...
<footer>$share_bar</footer>The part is rendered once and printed twice. The admin4l pagelayout uses this to render zones of the admin layout into
variables ({set-block variable=$header_html}...{/set-block}) and place them later.
append-block
Adds each body to a list:
append-block scope=global variable=page_notes
<li>'Updated today'|i18n( 'design/mytheme' )</li>
/append-blockScope
scope=global and scope=root write the variable outside the current template, so a view template can hand a value to
the code that called it. Mail templates use it for the subject:
set-block scope=root variable=subject'Your order'|i18n( 'design/mytheme/mail' )/set-blockand full views for their view cache lifetime:
set-block scope=root variable=cache_ttl400/set-block(the ezwebin event calendar). cache_ttl is a lifetime in seconds and only works in the content view; since 6.0.15
it is read as cache_until( time() + cache_ttl ). For output that changes at a known time, prefer
{cache_until( 'tomorrow' )} or {cache_until( $event_start )}, which works in every template and reaches every
cache (cache_until and seconds_until). For values the pagelayout needs, prefer the persistent variable
(The persistent variable).
Uses in the shipped templates
cache_ttlin full views (ezwebin'sfull/event_calendar.tpl,full/multicalendar.tpl).- Rendering parts once in the admin4l pagelayout.
- Mail subjects and headers in mail templates.
Related pages
- Variables and def
- Caching for designers
- cache_until and seconds_until
- 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.