Template Operators

Inside Template Operators

How template operators work

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.
 
[TemplateSettings]
AutoloadPathList[]=extension/ezgpg/autoloads
  • Insert an echo statement in your templatate operators autoload php file. From file, 'extension/ezgpg/autoloads/eztemplateautoload.php'
<?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
[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