Forums / Developer / Function "xxx" is not registered

Function "xxx" is not registered

Author Message

Damien MARTIN

Thursday 10 December 2009 7:32:34 am

Hi there,

I currently have a problem writing template operators.

I used Felix Woldt's tutorial who works very well but I would like to use different operators and not a single operator with different behaviour based on arguments.

So, I tried something like this :

eztemplateautoload.php

<?php
    
    $eZTemplateOperatorArray = array();
    
  
  $eZTemplateOperatorArray[] = array(    'script' => 
'extension/moo/autoloads/mooperator.php', 
                          
                  'class' => 'MOOperator',
                       
                     'operator_names' => array(
                  
                              
                                      
          'moo',
                                               
 'moo_hello_world'
                                                
  
                                          ) ); 
?>

mooperator.php

<?php
    
    class MOOperator{
        
        function MOOperator(){}
        
        function operatorList(){
            
            return array(
                
                'moo',
                'moo_hello_world'
                
            );
            
        }
        
        function namedParameterPerOperator(){
            
            return true;
        
        }
        
        function namedParameterList(){
            
            return array(
                
                'moo' => array( 'params' => array() ),
                
                'moo_hello_world'     => array(     
                                                    'params' => array(  'type' => 'array', 'required' => false, 'default' => array()  )
                                                )
                
            );
        
        }
        
        function modify(     $tpl, 
                            $operatorName, 
                            $operatorParameters, 
                            $rootNamespace, 
                            $currentNamespace, 
                            $operatorValue, 
                            $namedParameters){
            
            switch($operatorName){
                
                case "moo":
                    // $namedParameters['result_type'];
                    $operatorValue = "";
                    break;
                    
                case "moo_hello_world":
                    $operatorValue = Test::helloWorld();
                    break;
                
            }
            
        }
    
    }

?>

But nothing appends.

eZ Debug

Undefined index:  moo in /var/www/espace/lib/eztemplate/classes/eztemplate.php on line 660
Function "moo" is not registered

Could you say to me what is wrong with my code ?

I used Felix's tutorial and I used the code of ezstarrating and I don't see where I made mistakes...

Thanks

Damien

Jean-Luc Nguyen

Thursday 17 December 2009 9:36:10 am

Hello there, try to regenerate autoload classes:

sudo php bin/php/ezpgenerateautoloads.php

http://www.acidre.com

Giovanni Gigante

Sunday 17 January 2010 7:26:54 am

Note that in your template you should call {moo()} with parentheses, even if there are no arguments. Just using {moo} does not work and produces a 'Function "moo" is not registered' message.