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

Logic and comparison operators

The operators that build conditions: eq, ne, lt, gt, le, ge, and, or, not, true, false, null, choose, and the type tests is_set, is_unset, is_array, is_string, is_numeric, is_object, is_null, get_type, get_class.

Download as PDF

Address: https://doc.exponential.earth/exphelp/viewer/help/designers/templates/logic-and-comparison-operators.md

On this page

Logic and comparison operators

This page is a reference for conditions in templates. Logic operators come from eZTemplateLogicOperator, type tests from eZTemplateTypeOperator (lib/eztemplate/classes/).

Contents

  1. Comparison
  2. Logic
  3. Constants
  4. Type tests
  5. choose

Comparison

OperatorMeans
eq( $a, $b )equal (also $a|eq( $b ))
ne( $a, $b )not equal
lt, leless than, less or equal
gt, gegreater than, greater or equal

eq with more than two values is true when all are equal; matching is loose (0 equals false()).

Note

lt, le, gt and ge compare counts, as the class's comment defines them: a number is its value, an array its number of items, an object its number of attributes, a boolean 0 or 1, and any other string its length. So $children|gt( 3 ) means "more than three children", and '10'|gt( 9 ) compares numbers, but a non-numeric string is compared by length. Compare dates as timestamps (numbers).

Logic

{if and( $node.can_edit, $current_user.is_logged_in )} ... {/if}
{if or( $a, $b, $c )} ... {/if}
{if $node.is_hidden|not} ... {/if}

and returns the last true value (or false), or the first true value, so or( $title, $name ) also works as "the first non-empty" (but first_set tests "set" rather than "true").

Constants

true() and false() create booleans. null is a test: $value|null is true when the value is null.

Type tests

OperatorTrue when the value
is_set( $x ) / is_unset( $x )is defined / is not
is_array, is_string, is_integer, is_float, is_numeric, is_booleanhas that type
is_object, is_class( 'eZContentObjectTreeNode' )is an object, of that class
is_nullis null

get_type and get_class return the type and the class name, useful while debugging.

choose

$index|choose( 'zero', 'one', 'two' ) returns the parameter at the position of the input: a compact way to map a small number to a text. For true/false, cond() is clearer.

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