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: http://ez.no/community/forum/developer/operator_to_strip_off_html_tags
Use the OWSimpleOperator or Wrap Operator extension to create your own template operators or use all available php functions.
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.
Article provided by eZpedia
All text is available under the terms of the GNU Free Documentation License
Powered by eZ Publish 6.0.2stable
Hosted by USA eZ Publish Community Partner : Brookins Consulting