Forums / Developer / modify function in eztemplatestringoperator.php

"Please Note:
  • At the specific request of Ibexa we are changing this projects name to "Exponential" or "Exponential (CMS)" effective as of August, 11th 2025.
  • This project is not associated with the original eZ Publish software or its original developer, eZ Systems or Ibexa".

modify function in eztemplatestringoperator.php

Author Message

James Ward

Thursday 19 March 2009 1:35:04 pm

I wanted to modify the pad function (to allow for non-breaking spaces to be added) so I did a quick search for pad in the Exponential code (using version 4.0.1).

I noticed after some tinkering that the case for PadName under the function:

/*
     The modify function takes care of the various operations.
    */
      function modify( $tpl,
                     $operatorName,
                     $operatorParameters,
                     $rootNamespace,
                     $currentNamespace,
                     &$operatorValue,
                     $namedParameters,
                     $placement )

never gets used. It appears instead that the somewhat less friendly:

                                   'pad' => array( 'return' => 'string',
                                                   'code' => '$result = $paramCount == 2 ? str_pad( $staticValues[0], $staticValues[1] ) : str_pad ( $staticValues[0], $staticValues[1], $staticValues[2] );',
                                                   'code2' => '$result = str_pad( $staticValues[0], $staticValues[1] );',
                                                   'code3' => '$result = str_pad( $staticValues[0], $staticValues[1], $staticValues[2] );',
                                                 ),

Is what actually gets used to perform the pad operation. This seems like an ugly place to modify the pad behavior and I would like to adjust the code inside the modify function instead if possible.

Can someone explain the purpose of the modify function and when it gets called? I found nothing in the documentation and the comment leaves a bit to be desired.

Thanks in advance.

working at www.wardnet.com
blogging at www.jamesward.ca