Template Operators


Template operators plug into the Template system in eZ publish and are programmed in PHP. Template Operators can take input, transform it, and return a result to the template. eZ publish comes with a lot of built in template operators.


If you looking to save yourself a lot of development time and your not using a certified platform (re: eZ Publish Now) we suggest you use the wrap operator

Inside Template Operators

How template operator usage

Typical usage of a template operator is like this:


How template operators work

Template operators provide a template language function for your existing php function.

When to create a template operator?

If you have a lot of loops, ifs and fetches to manipulate variables, that is usually a good idea to put in an template operator.

What can you do

It is typically useful for:

  •  Manipulating variables ( arrays, strings, numbers, etc )
  •  Extracting information from eZ publish or external system
  •  a combination of the above

Creating a template operator

In the administration interface of eZ publish there is a wizard that helps you creating template operators. Go to "Setup" - "RAD" - "Template Operator wizard"

Put more detailed example here..

When to use template operators? Why there are so few template operators or documentation on them as a category or subject?

How to enable a template operator

How to debug a template operator not loading error
  1.  Settings - If valid settings are not properly configured your template operator will not be loaded
  2.  Code - If you have a code problem with your template operator.
Debug Tip
  •  Ensure that the autoloads directory for your template operator is properly configured in the settings

From file, ' extension/ezgpg/settings/site.ini.append'

#?ini charset="iso-8859-1"?
# eZ publish configuration file.

  •  Insert an echo statement in your templatate operators autoload php file. From file, 'extension/ezgpg/autoloads/eztemplateautoload.php'

eZDebug::writeWarning( 'eZGPGOperators::autoload : load template operator' );

echo("eZGPGOperators::autoload : load template operator || is loaded ...<hr /><hr />");
// Operator autoloading

$eZTemplateOperatorArray = array();
$eZTemplateOperatorArray[] = array( 'script' => 'extension/ezgpg/autoloads/ezgpg_operators.php',
                                    'class' => 'eZGPGOperators',
                                    'operator_names' => array( 'ezgpg_decode' ) );


When to use a template operator

When you need to provide a feature via function in templates.

Why to use a template operator

It is the only way to access additional user defined features without kernel or extension modification

Using PHP functions as template variables

  1.  strip html tags

To remove html tags from a string.
 In template.ini(.append.php)
 add under
 Then in your template use
 and catch the stripped output
 See: http://ez.no/community/forum/developer/operator_to_strip_off_html_tags

Creating your own template variables in a simpler way

Use the OWSimpleOperator or Wrap Operator extension to create your own template operators or use all available php functions.

Listing all available template operators using ggsysinfo extension

Use the ggsysinfo extension which provides a module view to list all available operators and which extension they might belong.

This view is amazing because you can quickly determine which template operators might be used within a giving eZ Publish installation.


If eZ Publish doesn't seem to want to load your template operator, then you might want to check out some useful tips to get it to work at the Troubleshooting extensions page.