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.