Share » Forums » Developer » Custom tpl operator parameter ?

Custom tpl operator parameter ?

Custom tpl operator parameter ?

Saturday 14 January 2006 6:53:30 am - 1 reply

Author Message

Norman Leutner

Sunday 15 January 2006 1:08:43 am

What about posting your code here?

here a small example:

<?php

class FakePriceOperators
{
    /*!
     Constructor
    */
    function FakePriceOperators()
    {
        $this->Operators = array( 'fake_price');
    }

    /*!
     Returns the operators in this class.
    */
    function &operatorList()
    {
        return $this->Operators;
    }

    /*!
     \return true to tell the template engine that the parameter list
    exists per operator type, this is needed for operator classes
    that have multiple operators.
    */
    function namedParameterPerOperator()
    {
        return true;
    }

    /*!
     The first operator has two parameters, the other has none.
     See eZTemplateOperator::namedParameterList()
    */
    function namedParameterList()
    {
        return array( 'fake_price' => array( 'fake_percent' => array( 'type' => 'string',
                                                                 'required' => false,
                                                                 'default' => '20' ) ) );
    }

    /*!
     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 'fake_price':
            {
                $operatorValue = $operatorValue * (100 - $namedParameters['fake_percent']) / 100;
            } break;
        }
    }

    /// \privatesection
    var $Operators;
}

?>

Seems like:

    function namedParameterList()
    {
        return array( 'fake_price' => array( 'fake_percent' => array( 'type' => 'string',
                                                                 'required' => false,
                                                                 'default' => '20' ) ) );
    }

Is missing in your extension.

Mit freundlichen Grüßen
Best regards

Norman Leutner

____________________________________________________________
eZ Publish Platinum Partner - http://www.all2e.com
http://ez.no/partners/worldwide_partners/all2e_gmbh

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu