Template operator to implement counter

Author Message

Nebojsa Eric

Friday 26 May 2006 3:13:51 am

I`m trying to implement different type of counters into my project. This function inside my custom template operator should do the job. But it`s not working. Maybe someone can say why this code returns nothing? Debug output: Object problem with operator 'getcounter'.

include_once( 'lib/ezdb/classes/ezdb.php' );
include_once( 'kernel/classes/ezcontentobjecttreenode.php' );
/* Update class attribute with A + 1 result. */
function getcounter( $nodeid, $attributeid ) {
$anode =& eZContentObjectTreeNode::fetch( $nodeid );
if ( !$anode )
{
eZDebugSetting::writeDebug( 'kernel-notification',
'Newsletter module: No node with ID: ' . $nodeid );
return;
}
$anodeObject =& $anode->object();
$attributes =& $anodeObject->contentObjectAttributes();
$atvalue = $attributes[$attributeid]->content(); // 1st attribute is hit counter
$atvalue = $atvalue + 1;
$attributes[$attributeid]->setAttribute( "integer", $atvalue );
$attributes[$attributeid]->store();

return $atvalue;
}

Nebojsa Eric

Monday 29 May 2006 3:53:19 am

I`ve fixed this template operator. It`s now working but only when I click on Clear Cache button. Then I can see that attribute content is acctualy incremented. How to make it work without clear cache?

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 18 2025 19:39:22
Script start
Timing: Jan 18 2025 19:39:22
Module start 'layout'
Timing: Jan 18 2025 19:39:22
Module start 'content'
Timing: Jan 18 2025 19:39:23
Module end 'content'
Timing: Jan 18 2025 19:39:23
Script end

Main resources:

Total runtime0.5443 sec
Peak memory usage4,096.0000 KB
Database Queries52

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0067 587.9297152.6250
Module start 'layout' 0.00670.0025 740.554739.4453
Module start 'content' 0.00920.5339 780.0000461.2578
Module end 'content' 0.54300.0013 1,241.25788.1563
Script end 0.5443  1,249.4141 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00320.5824160.0002
Check MTime0.00130.2441160.0001
Mysql Total
Database connection0.00200.372210.0020
Mysqli_queries0.500591.9602520.0096
Looping result0.00040.0696500.0000
Template Total0.516394.820.2581
Template load0.00200.372820.0010
Template processing0.514294.473520.2571
Template load and register function0.00010.016010.0001
states
state_id_array0.00080.151610.0008
state_identifier_array0.00070.126520.0003
Override
Cache load0.00170.3134270.0001
Sytem overhead
Fetch class attribute can translate value0.00050.083610.0005
Fetch class attribute name0.00090.165030.0003
XML
Image XML parsing0.00050.086010.0005
class_abstraction
Instantiating content class attribute0.00000.001440.0000
General
dbfile0.00080.1389160.0000
String conversion0.00000.001740.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
2content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
2content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
4content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
2content/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: 12
 Number of unique templates used: 6

Time used to render debug report: 0.0001 secs