Path

ez.no / exponential / documentation / development / extensions / template operator / solution for passing the parameters


Solution for passing the parameters

Hi,

if you want to pass the parameter like this {$value|myfunction()}, you have to declare your function like this :



           function namedParameterList()


           {


                return array(


                 'myfunction' => array() );


           }


 

           /*!


            Executes the needed operator(s).


            Checks operator names, and calls the appropriate functions.


           */


           function modify( &$tpl, &$operatorName, &$operatorParameters, $rootNamespace, &$currentNamespace, &$operatorValue, &$namedParameters )


           {


               switch ( $operatorName )


               {


                   case 'myfunction'


                   {


                       $operatorValue = $this->myfunction( $operatorValue );


                   } break;


               }


           }


 

           function myfunction($val)


           {


               code your funtion and return some value;


           }




the attention is in the modify's declaration of your function. You have to use the $operatorValue variable insteed of '$namedParameters'.
You can then call your template operator in your template with : {$value|myfunction()}

Modified by Garnier Mickael on 07/03/2008 at 2:13:00 am