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

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

eZ debug

Timing: Jan 30 2025 19:39:12
Script start
Timing: Jan 30 2025 19:39:12
Module start 'content'
Timing: Jan 30 2025 19:39:12
Module end 'content'
Timing: Jan 30 2025 19:39:13
Script end

Main resources:

Total runtime0.3097 sec
Peak memory usage8,192.0000 KB
Database Queries141

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0079 588.5469370.2266
Module start 'content' 0.00790.0132 958.77341,005.8281
Module end 'content' 0.02120.2885 1,964.60163,905.2109
Script end 0.3097  5,869.8125 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00431.3774200.0002
Check MTime0.00130.4096200.0001
Mysql Total
Database connection0.00080.245110.0008
Mysqli_queries0.218870.63431410.0016
Looping result0.00140.45921390.0000
Template Total0.288193.010.2881
Template load0.00080.274410.0008
Template processing0.287392.746810.2873
Override
Cache load0.00060.202810.0006
Sytem overhead
Fetch class attribute can translate value0.00160.517210.0016
XML
Image XML parsing0.00030.081110.0003
General
dbfile0.01073.4519200.0005
String conversion0.00000.001530.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
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0002 secs