📚 Looking for current Exponential documentation? This site contains legacy SDK & API reference docs (eZ Publish era). For up-to-date 2026 product documentation, visit doc.exponential.earth.

  eztemplate / basic_operators  

<< Attributes  Functions >> 

Operators

TODO — Image not available in archive

Title:   Template Operator Architecture Diagram
File:    /doc/images/operator.png

What this image shows:
Diagram showing how custom template operators are registered and called within the eZ Template system. Illustrates the operator handler interface, how operators receive parameters and modify output within template expressions.

Replacement instructions:
Redraw based on sdk/kernel/view/template_operators documentation. Save as /doc/images/operator.png

See /sdk/missing.html for the full list of missing images.

Operators allow the template engine to modify variable types or create new values. Operators receive data input from the left and output the result to the right. How the operator modifies the data is up to each operator. For instance, some operators behave differently depending on whether the input data is an array or not, while others may ignore the input and create an output variable.

The operators can also take extra parameters separated by ',' (comma) and enclosed in '(' and ')' (brackets). The parameters can be constants, variables or operators which means that you can nest operators. For instance, there's no builtin syntax for creating booleans or arrays, instead you use an operator. true() creates a boolean with a true value and false() creates a boolean with a false value. array() takes all its parameters and creates an array out of it.

The general syntax for an operator is: {input|operator(parameter1,parameter2...)} Remember that both the input and the parameters can be operators. You could for instance write: {cond($b|ne(0),div($a,$b),0)} This example will divide $a by $b and return the result. If $b is null, however, it will not attempt to divide, and return null instead.

If you want to send input to the operator, then the input and the operator must be separated by '|' (the pipe symbol). If for instance you are calling an operator that takes three parameters, and you want to omit the second parameter, just write nothing at that position, e.g. {operator(parameter1,,parameter2)}.

Some operators work only on the logical level, meaning that they only see values as true or false. For consistency, all operators should follow these following rules: Arrays are true if the count is larger than 0, numerical values are true if the value is different than 0, booleans behave as normal, null is always false and all other values are false.

Examples of some variable operators:

{* Creating and showing an array *}
{array(1,5,'test')|attribute(,,show)}

{* Multiple serialized operators *}
{array(1,2)|gt(1)|choose('Tiny array','Greater than one')}
{* This will output 'Greater than one', because the array
consists of more than one element.*}

Exponential Copyright © 1998 - 2026 7x