Wednesday 25 May 2011 12:05:35 am
If you do not want to parse files, you could do something like this. Create a template operator called "viewcounter" and add the following code to your pagelayout
{cache-block expiry=1}{if and($current_node_id,gt($current_node_id,2))}{""|viewcounter($current_node_id)}{/if}{/cache-block} The template operator modify function should look something like this:
function modify( $tpl, $operatorName, $operatorParameters, $rootNamespace, $currentNamespace, $operatorValue, $namedParameters )
{
$nodeID = $namedParameters['node_id'];
switch ( $operatorName )
{
case 'viewcounter':
{
if ( is_numeric( $nodeID ) AND $nodeID > 0 )
$nodeObject = eZContentObjectTreeNode::fetch( $nodeID );
if ( $nodeObject != null )
{
$counter = eZViewCounter::fetch( $nodeID );
if ( $counter == null )
$counter = eZViewCounter::create( $nodeID );
$counter->increase();
}
}
} break;
}
}
} The code is for older versions of eZ, so it probably has to be updated.
Certified eZ publish developer with over 9 years of eZ publish experience. Available for challenging eZ publish projects as a technical consultant, project manager, trouble shooter or strategic advisor.
|