Forums / Developer / new operator

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!

eZ debug

Timing: Jan 18 2025 16:08:11
Script start
Timing: Jan 18 2025 16:08:11
Module start 'content'
Timing: Jan 18 2025 16:08:11
Module end 'content'
Timing: Jan 18 2025 16:08:12
Script end

Main resources:

Total runtime0.9032 sec
Peak memory usage4,096.0000 KB
Database Queries194

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0055 588.6719180.8516
Module start 'content' 0.00560.7286 769.5234488.8047
Module end 'content' 0.73410.1690 1,258.3281333.5000
Script end 0.9031  1,591.8281 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00390.4347210.0002
Check MTime0.00150.1690210.0001
Mysql Total
Database connection0.00060.066510.0006
Mysqli_queries0.818590.62871940.0042
Looping result0.00210.22911920.0000
Template Total0.874796.820.4373
Template load0.00230.255720.0012
Template processing0.872396.583220.4362
Template load and register function0.00020.027210.0002
states
state_id_array0.00100.113110.0010
state_identifier_array0.00100.110520.0005
Override
Cache load0.00200.2211280.0001
Sytem overhead
Fetch class attribute can translate value0.00160.181030.0005
Fetch class attribute name0.00160.172030.0005
XML
Image XML parsing0.00050.052730.0002
class_abstraction
Instantiating content class attribute0.00000.001030.0000
General
dbfile0.00981.0882210.0005
String conversion0.00000.000730.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
3content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
4content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
9content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
5content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 23
 Number of unique templates used: 6

Time used to render debug report: 0.0001 secs