Skip to the content
Documentation
Help Start
Reading in:
  • German: 9,110 of 9,110 pages
About the help in other languages
All help pages

Set-block and append-block

Capturing rendered output into a variable with set-block, collecting several pieces into a list with append-block, the scope parameter, and typical uses (rendering a part once and printing it twice, mail subjects…

Download as PDF

Address: https://doc.exponential.earth/exphelp/viewer/help/designers/templates/set-block-and-append-block.md

On this page

Set-block and append-block

This page is for designers who need rendered markup in a variable instead of in the output.

Contents

  1. set-block
  2. append-block
  3. Scope
  4. Uses in the shipped templates

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-block}

Scope

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-block}

and full views for their view cache lifetime:

{set-block scope=root variable=cache_ttl}400{/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_ttl in full views (ezwebin's full/event_calendar.tpl, full/multicalendar.tpl).
  • Rendering parts once in the admin4l pagelayout.
  • Mail subjects and headers in mail templates.

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.

Something wrong on this page? Report an error

Documentation license

This documentation is free documentation, licensed under the GNU Free Documentation License 1.3 or later.

Exponential Copyright © 1998-2026 Exponential Foundation and 7x