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

String operators

The classic string operators of the template library (upcase, downcase, upfirst, upword, trim, shorten, wrap, pad, simplify, count_chars, count_words, nl2br, concat, indent, break, chr, ord) with examples, and where the…

Download as PDF

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

On this page

String operators

This page is for designers who shape text in templates. These operators come from eZTemplateStringOperator, eZTemplateTextOperator and eZTemplateNl2BrOperator (lib/eztemplate/classes/). Since 6.0.13, about sixty PHP string functions are operators as well (PHP string functions as operators).

Contents

  1. Case
  2. Length and trimming
  3. Joining and layout
  4. Counting
  5. Escaping comes last

Case

OperatorResult for 'hello world'
upcaseHELLO WORLD
downcasehello world
upfirstHello world
upwordHello World

Prefer CSS text-transform for purely visual case: screen readers and copy-paste keep the original text.

Length and trimming

{$node.name|shorten( 60 )}                 {* at most 60 characters, '...' added when cut *}
{$text|shorten( 120, '…' )}                {* own ending *}
{$text|trim}                               {* spaces removed at both ends *}
{$text|simplify}                           {* runs of spaces reduced to one *}
{$code|pad( 6, '0' )}                      {* str_pad: '42' becomes '420000' *}
{$text|wrap( 72 )}                         {* wordwrap at 72 characters *}

shorten defaults: length 80, sequence ..., cut on the right (from the operator's code). For rich text, shorten the plain text: {$node.data_map.intro.content.output.output_text|strip_tags|shorten( 160 )|wash}.

Joining and layout

{concat( $first, ' ', $last )}
{$text|nl2br}            {* line breaks to <br>: wash first *}
{$text|break}            {* the same as nl2br in the string operator *}
{'x'|indent( 4 )}        {* indentation *}

chr and ord convert between characters and codes.

Counting

{$text|count_words}
{$text|count_chars}       {* multibyte aware: mb_strlen when available *}

Escaping comes last

Shape first, then wash: {$text|shorten( 100 )|wash}. For nl2br, wash before it so the <br> survives: {$text|wash|nl2br} (Wash and escaping).

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