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

tipafriend_top_list

Summary

Fetches the most popular (most tipped) nodes.

Usage

fetch( 'content', 'tipafriend_top_list',
     hash( [ 'offset',     offset,     ]
           [ 'limit',      limit,      ]
           [ 'start_time', start_time, ]
           [ 'end_time',   end_time,   ]
           [ 'duration',   duration,   ]
           [ 'ascending',  ascending,  ]
           [ 'extended',   extended    ] ) )

Parameters

NameTypeDescriptionRequired
offset integer The offset to start at. No.
limit integer The number of nodes that should be returned. No.
start_time integer The time to start at. No.
end_time integer The time to end at. No.
duration integer The period of time that should be used. No.
ascending boolean The sorting direction that should be used. If FALSE (default), the results will be sorted descending by the number of times each node was tipped. No.
extended boolean If TRUE, an array of hashes will be returned. No.

Returns

An array of ezcontentobjecttreenode objects, an array of hashes (see below) or FALSE.

Description

This function fetches the nodes that were most tipped using the "Tip a friend" feature. The "Tip a friend" feature can be accessed by requesting the "tipafriend" view of the "content" module, it takes a node ID as a parameter, for example: "http://www.example.com/content/tipafriend/44".

The returned result is sorted by the number of times the nodes were tipped. The sorting direction can be controlled using the "ascending" parameter, it can be set to either TRUE or FALSE (default).

The "limit" and "offset" parameters can be used to control the number of items returned and the offset to start at.

The "start_time", "end_time" and "duration" parameters can be used to specify a time period that the function should operate within. These parameters make it possible to fetch the most popular/tipped nodes for a certain period of time (for example last 24 hours, last week, last month, etc.). If the "start_time" and "duration" parameters are specified, results for the "start_time+duration" period of time will be fetched. If the "end_time" and "duration" parameters are specified, results for the "end_time-duration" period of time will be fetched. If all of these parameters are omitted, the function will cover all nodes, regardless when they were tipped. If both the "start_time" and "duration" parameters are omitted, then only results for the period before "end_time" will be fetched. If only the "start_time" or "duration" parameter is set, the function will automatically use the current time as the "end_time" parameter.

By default (when the "extended" parameter is FALSE), the function returns an array of ezcontentobjecttreenode objects. If the "extended" parameter is set to TRUE, the function will return an array of the following hashes:

Key

Type

Description

node_id

string

The ID number of the node.

count

string

The number of times the node was tipped.

node

object

The node itself (as an ezcontentobjecttreenode object).

If the function is unable to find any tipped nodes or if an error occurs, it will return FALSE.

Examples

Example 1

{def $popular_nodes=fetch( 'content', 'tipafriend_top_list',
                     hash( 'limit',  10,
                           'offset', 0,
                           'start_time', maketime( 0, 0, 0 ),
                           'duration', mul( 60, 60, 24 )
                            ) )}
 
{foreach $popular_nodes as $popular_node}
    {$popular_node.name|wash} <br />
{/foreach}
{undef}

Outputs the names of the ten most popular nodes during the last 24 hours. The "start_time" parameter sets 00:00:00 as the time and the current date. The "duration" parameter is set to a period that equals one day (60 seconds x 60 minutes x 24 hours).

Example 2

{def $popular_nodes=fetch( 'content', 'tipafriend_top_list',
                     hash( 'ascending', false(),
                           'extended', true()
                          ) )}
{foreach $popular_nodes as $popular_node}
    <tr>
         <td>{$popular_node.node.name|wash}</td>
         <td>{$popular_node.count}</td>
    </tr>
{/foreach}
{undef}

Generates a list of popular nodes by outputting their names and the number of times they were tipped. The results are sorted by the number of times the nodes were tipped.

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

Balazs Halasy (13/05/2007 1:53 pm)

Balazs Halasy, Julia Shymova


Comments

There are no comments.