Table of contents:
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
Typical usage of a template operator is like this:
{'input'|mytploperator('param1','param2')}
Template operators provide a template language function for your existing php function.
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.
It is typically useful for:
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?
From file, 'extension/ezgpg/settings/site.ini.append'
#?ini charset="iso-8859-1"? # eZ publish configuration file. [TemplateSettings] AutoloadPathList[]=extension/ezgpg/autoloads
<?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 you need to provide a feature via function in templates.
It is the only way to access additional user defined features without kernel or extension modification
To remove html tags from a string.
=============================
In template.ini(.append.php)
add under
[PHP]
....
PHPOperatorList[striptags]=strip_tags
......
Then in your template use
$yourstring_with_xml|striptags
and catch the stripped output
=============================
See: https://ez.no/community/forum/developer/operator_to_strip_off_html_tags