Monday 21 March 2011 8:02:13 pm
I am having problems implementing a custom template operator. The only hint I got was: "Yes - use the $eZTemplateFunctionArray variable in a eztemplateautoload.php file in the autoloads dir of an extension" So I looked for examples on how to do that and I've done "my own":
<?
class my_temp_op
{
function my_temp_op()
{
}
function operatorList()
{
return array( 'my_op');
}
function namedParameterPerOperator()
{
return true;
}
function namedParameterList()
{
return array( 'my_op' => array( 'type' => 'string',
'required' => true,
'default' => '' )
);
}
function modify( $tpl, $operatorName, $operatorParameters, $rootNamespace, $currentNamespace, &$operatorValue, $namedParameters )
{
switch ( $operatorName )
{
case 'my_op':
{
$operatorValue = 'outputtext';
} break;
}
}
} ?> And I expect when {using my_op('something')} in a template to get 'outputtext'. The problem is that this is not happening. Here is the definition of the templateoperator:
<?
$eZTemplateOperatorArray = array();
$eZTemplateOperatorArray[] = array( 'script' => 'extesion/myext/autoloads/my_op_file.php',
'class' => 'my_temp_op',
'operator_names' => array( 'my_op') ); ?> Any help, please? Also, a tutorial about this would be appreciated... I do not understand how one wants to grow a community without giving proper documentation about the object that the community is gathered around.
|