Caution: This documentation is for eZ Publish legacy, from version 3.x to 5.x.
For 5.x documentation covering Platform see eZ Documentation Center, for difference between legacy and Platform see 5.x Architecture overview.

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

Balazs Halasy (06/02/2004 1:24 pm)

Balazs Halasy (28/04/2005 2:01 pm)


Comments

There are no comments.