Caution: This documentation is for eZ Publish legacy, from version 3.x to 6.x.
For 5.x documentation covering Platform see eZ Documentation Center, for difference between legacy and Platform see 5.x Architecture overview.

view_top_list

Summary

Fetches the most popular (most viewed) nodes.

Usage

fetch( 'content', 'view_top_list',
       hash( [ 'section_id', section_id, ]
             [ 'class_id',   class_id,   ]
             [ 'offset',     offset,     ]
             [ 'limit',      limit       ] ) )

Parameters

NameTypeDescriptionRequired
section_id integer The ID number of the section. No.
class_id integer The ID number of the class. No.
offset integer The offset to start at. No.
limit integer The number of nodes that should be returned. No.

Returns

An array of ezcontentobjecttreenode objects.

Description

This function fetches the most popular (most viewed) nodes. The function returns an array of ezcontentobjecttreenode objects. The "section_id" and "class_id" parameters can be used to filter out objects of certain type and/or objects that belong to a certain section. The "offset" and "limit" parameters can be used to limit the result.

In order to work, this function requires the use of the cronjob script. A part of this script will update the view counters of the nodes by analyzing the Apache log files. The "Scripts[]" array of a configuration override for "cronjob.ini" should include the "updateviewcount.php" script:

...
Scripts[]=updateviewcount.php
...

In addition, the logfile settings in "logfile.ini" should match the syntax of the Apache log files.

Examples

Example 1

{def $popular_nodes=fetch( 'content', 'view_top_list',
                           hash( 'class_id',  2,
                                 'limit',    10,
                                 'offset',    0 ) )}
 
{foreach $popular_nodes as $popular_node}
    {$popular_node.name|wash} <br />
{/foreach}

Outputs the names of the ten most popular nodes that encapsulate objects of class number 2.

Balazs Halasy (06/02/2004 12:16 pm)

Balazs Halasy (29/04/2005 9:05 am)


Comments

  • Parent node id

    Is there a way to use parentnode id instead of sectionid to get the same result? I tried, but i got mainly nodes from the top node ( node_id=2 )