Custom extension created to for an operator to fetch fixed number of characters is not working

Author Message

Romeo Antony

Tuesday 29 June 2010 3:53:36 pm

Hi, can anyone go through this script and find out what is wrong with it.

I have created a custom operator called "charactertrunc " to fetch fixed number of characters from content nodes.but after activating this extension getting

Fatal error: eZ Publish did not finish its request

The execution of eZ Publish was abruptly ended. Contact website owner with current url and what you did, and owner will be able to debug the issue further.

I show you the code . files are

extension/charactertrunc/autoloads/templatecharactertruncoperator.php

extension/charactertrunc/autoloads/eztemplateautoload.php

extension/charactertrunc/settings/site.ini.append

1. in site.ini.append

<?php
[TemplateSettings]
ExtensionAutoloadPath[]=charactertrunc
?>

2. in eztemplateautoload.php

<?php
// Operator autoloading
$eZTemplateOperatorArray = array();
$eZTemplateOperatorArray[] = array( 'script' => 'extension/charactertrunc/autoloads/templatecharactertruncoperator.php',
'class' => 'TemplateCharactertruncOperator',
'operator_names' => array( 'charactertrunc' ) );
?>

3. in templatecharactertruncoperator.php

<?php
class TemplateCharactertruncOperator
{

function TemplateCharactertruncOperator()
{

}
function operatorList()
{
return array( 'charactertrunc' );
}
function namedParameterPerOperator()
{
return true;
}

function namedParameterList()
{
return array( 'charactertrunc' => array( 'number' => array( 'type' => 'integer',
'required' => false,
'default' => 0 ) ) );

}
function modify( $tpl, $operatorName, $operatorParameters, $rootNamespace, $currentNamespace, &$operatorValue, $namedParameters, $placement )
{
$number = $namedParameters['number'];
// Example code. This code must be modified to do what the operator should do. Currently it only trims text.
switch ( $operatorName )
{
case 'charactertrunc':
{





$operatorValue = $this->substr($operatorValue,0,$number);


} break;
}
}

}
?>

I have put something wrong

I hope a help plz . Thanks in advance Romeo.

Norman ROCHE

Wednesday 30 June 2010 12:35:36 am

Hi,

I did not check your code but I think you should have a look to this as that does pretty much the same thing:

http://ez.no/doc/ez_publish/technical_manual/4_x/reference/template_operators/strings/extract_left

even If I think that what you do really need is :

http://ez.no/doc/ez_publish/technical_manual/4_x/reference/template_operators/strings/shorten

Cheerz

Romeo Antony

Wednesday 30 June 2010 2:18:21 am

Thank you for helping me

Bertrand Dunogier

Wednesday 30 June 2010 5:17:57 am

Have you regenerated extensions autoloads after enabling the extension ?

In any case, a fatal error will usually give more information with site.ini/DebugSettings.DebugOutput = enabled.

Bertrand Dunogier
eZ Systems Engineering, Lyon
http://twitter.com/bdunogier
http://gplus.to/BertrandDunogier

Romeo Antony

Friday 02 July 2010 2:09:30 am

Bertrand, I have regenerated extensions autoloads.But now it is working only when I change this line $operatorValue = $this->substr($operatorValue,0,$number); to $operatorValue =substr($operatorValue,0,$number);

thank you for helping me ...Romeo

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 30 2025 22:23:13
Script start
Timing: Jan 30 2025 22:23:13
Module start 'layout'
Timing: Jan 30 2025 22:23:13
Module start 'content'
Timing: Jan 30 2025 22:23:14
Module end 'content'
Timing: Jan 30 2025 22:23:14
Script end

Main resources:

Total runtime1.2920 sec
Peak memory usage8,192.0000 KB
Database Queries65

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0060 588.6406151.2734
Module start 'layout' 0.00600.0047 739.9141220.8594
Module start 'content' 0.01071.2805 960.77344,518.4688
Module end 'content' 1.29120.0008 5,479.242215.7031
Script end 1.2920  5,494.9453 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00350.2731160.0002
Check MTime0.00120.0949160.0001
Mysql Total
Database connection0.00070.050510.0007
Mysqli_queries1.186291.8086650.0182
Looping result0.00060.0481630.0000
Template Total1.231095.320.6155
Template load0.00200.153520.0010
Template processing1.229095.125520.6145
Template load and register function0.00130.104210.0013
states
state_id_array0.00190.144810.0019
state_identifier_array0.00200.151620.0010
Override
Cache load0.00180.1407930.0000
Sytem overhead
Fetch class attribute can translate value0.00200.157430.0007
Fetch class attribute name0.00190.148970.0003
XML
Image XML parsing0.00270.208730.0009
class_abstraction
Instantiating content class attribute0.00000.001690.0000
General
dbfile0.00390.3046220.0002
String conversion0.00000.000840.0000
Note: percentages do not add up to 100% because some accumulators overlap

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
4content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
5content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
9content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
1content/datatype/view/ezxmltags/strong.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/strong.tplEdit templateOverride template
3content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 24
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs