Custom tpl operator parameter ?

Author Message

H-Works Agency

Saturday 14 January 2006 6:53:30 am

I have a problem with my custom template operator 'age'.

It is only working when passing the parameter like this : {age(parameter)}
But not like this, as it should be : {parameter|age}

What can make it act so ?

I based my work on the creating custom operator extension document :
http://ez.no/products/ez_publish_cms/documentation/development/extensions/template_operator

Martin

EZP is Great

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

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 18 2025 19:17:57
Script start
Timing: Jan 18 2025 19:17:57
Module start 'layout'
Timing: Jan 18 2025 19:17:57
Module start 'content'
Timing: Jan 18 2025 19:17:57
Module end 'content'
Timing: Jan 18 2025 19:17:57
Script end

Main resources:

Total runtime0.0300 sec
Peak memory usage2,048.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0156 587.9141152.6250
Module start 'layout' 0.01560.0045 740.539139.4453
Module start 'content' 0.02010.0071 779.984489.4453
Module end 'content' 0.02720.0028 869.429734.3047
Script end 0.0300  903.7344 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.003411.2728140.0002
Check MTime0.00144.6951140.0001
Mysql Total
Database connection0.00175.649910.0017
Mysqli_queries0.007725.706130.0026
Looping result0.00000.086610.0000
Template Total0.00227.210.0022
Template load0.00134.280510.0013
Template processing0.00092.865110.0009
Override
Cache load0.00092.994510.0009
General
dbfile0.00196.451480.0002
String conversion0.00000.050040.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs