new operator

Author Message

tic 9

Thursday 26 June 2008 4:48:45 am

hi!
I am spirit to develop a simple operator who does not make post just an end of sentence but the problem is that i have an error.
here all configurations:

in settings/my-siteaccess/site.ini

[ExtensionSettings]
ActiveAccessExtension[]=essai

I have in my extension:
extension/essai/ autoloads/eztemplateautoload.php

   <?php

                                    
                                    
                                    
                                 
$eZTemplateOperatorArray = array();
$eZTemplateOperatorArray[] = array( 'script' => 'extension/essai/autoloads/templatembuyi1operator.php',
                                    'class' => 'TemplateMbuyi1Operator',
                                    'operator_names' => array( 'mbuyi1' ) );
?>
 

and extension/essai/ autoloads/templatembuyi1operator.php

 


class TemplateMbuyi1Operator

{

<?php
    /*!
      Constructeur
    */
   function TemplateMbuyi1Operator
    {
    }

    /*!
     
return an array with the template operator name.
    */
    function operatorList()
    {
        return array( 'mbuyi1' );
    }
    /*!
     \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;
    }    /*!
     See eZTemplateOperator::namedParameterList
    */
    function namedParameterList()
    {
        return array( 'mbuyi1' =>  array('');
    }
    /*!
     Exécute la fonction PHP correspondant à l'opérateur "cleanup" et modifie \a $operatorValue.
    */
    function modify( &$tpl, &$operatorName, &$operatorParameters, &$rootNamespace, &$currentNamespace, &$operatorValue, &$namedParameters )
    {
      //  $firstParam = $namedParameters['first_param'];
       // $secondParam = $namedParameters['second_param'];
        // Exemple de code, ce code doit être modifié pour que l'opérateur fasse ce qu'il doit faire. Actuellement il effectue juste un "trim" du texte.
        switch ( $operatorName )
        {
            case 'mbuyi1':
            {
                   $operatorValue = $this->mbuyi1();
            } break;
        }
    }
    
    function mbuyi1()

   {

       return 'Hello World';

   }

 
/// privatesection

   var $Operators;

}

?>
 

in extension/essai/ settings/site.ini


<?php /* #?ini charset="iso-8859-1"?

# eZ publish configuration file for designs
[TemplateSettings]
ExtensionAutoloadPath[]=extension/essai/autoloads

*/ ?>
 

but, it don't run and I have this
eZTemplate @ extension/essai/design/standard/templates/pagelayout.tpl:59[5] Jun 26 2008 13:23:03

Operator 'mbuyi1' is not registered

Nicolas Ottavi

Thursday 26 June 2008 5:08:57 am

Hello

In your extension/essai/settings/site.ini.append.php you should have this

<?php /* #?ini charset="utf-8"?
[TemplateSettings]
ExtensionAutoloadPath[]=essai

*/ ?>

In your case you put extension/essai/autoloads in ExtensionAutoloadPath[] when you only need the extension folder name.

Hope it helps,
N.O

tic 9

Thursday 26 June 2008 5:29:33 am

Thank you very much for that!

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