append-block

Summary

Redirects the output from multiple blocks of template code to an array.

Usage

{append-block variable=$variable [ name=name ] [ scope=scope ]}
...
{/append-block}

Parameters

NameTypeDescriptionRequired
name string Name of the namespace. No.
scope string The scope ("global", "root" or "relative"). No.
variable string The name of variable that will be returned. Yes.

Description

This mechanism will silently process all template code which is encapsulated by "{append-block ...}" and "{/append-block}". It will not produce any actual output. Instead, the generated output will be assigned to a variable specified by the "variable" parameter (as an array). If the variable does not exist, it will be automatically created. If the same target variable is used in several blocks, the function will simply add new elements to the array and thus the previous contents will be preserved.

Examples

Example 1

{append-block variable=$alien}
    It seems to have a life,
{/append-block}
 
...
 
{append-block variable=$alien}
    organic life...
{/append-block}
 
...
 
{foreach $alien as $element}
    {$element} <br />
{/foreach}

This example demonstrates how to create an array called $alien using the "append-block" mechanism. The output from the code that is encapsulated by "{append-block ...}" and "{/append-block}" will be assigned as elements to the target variable. When the $alien array is inspected, the following output will be produced:

It seems to have a life,
organic life...

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