ibexa

Caution: This documentation is for eZ Publish legacy, from version 3.x to 5.x.

latest_comments_list

Summary

This function fetches the latest comments.

Usage

fetch( 'comment', 'latest_comment_list',
       hash([ 'user_id',       user_id,]
            [ 'user_email',    user_email,]
            [ 'length',        length,]
            [ 'use_modified',  use_modified, ]
            [ 'after',         after, ]
            [ 'sort_order',    sort_order] ) )

Parameters

NameTypeDescriptionRequired
user_id integer User id of the comment author No
user_email string User's email of the comment author. Useful for anonymous comment fetching No
length integer Number of record which will be fetched. If the number of records is less than length, all the records will be fetche No
use_modified boolean Use modified time for judging 'latest' instead of created time. By default it's false No
after integer Fetch comments after some time, yesterday for instance. The value is a UNIX timestamp No
sort_order string Sort order of the list. The value should be 'desc' or 'asc'. By default it's 'desc' No

Returns

Array if there is record, array() if there is no record under the conditions.

Description

This function fetches the latest comments based on some conditions. user_id and user_email can be used together or separately. Note that anonymous users have same user_id.

Examples

Example 1

{def $comments=fetch( 'comment', 'latest_comment_list',
                   hash( 'length', '15' ) )}
 {foreach $comments as $comment}
         {$comment.text} - {$comment.created|l10n( 'shortdatetime')}
         <br />
 {/foreach}

Fetches the latest 15 comments and outputs the comment content and time.

Example 2

{def $current_user = fetch( 'user', 'current_user' )}
 {def $comments = fetch( 'comment', 'latest_comment_list', hash( 'user_id',  $current_user.contentobject_id, 'length', 10 ) )}

Fetches the lastest 10 comments made by current user.

Note: this code will fetch all anonymous comments if the current user is anonymous. So it should run under a non-anonymous user view.

Example 3

{def $now=currentdate()}
 {def $gap = 24|mul( 60 )|mul( 60 )}
 {def $yesterday=$now|sub( $gap )}
 {def $comments = fetch( 'comment', 'latest_comment_list', hash( 'after',  $yesterday ) )}

Fetches comments created since yesterday.

Geir Arne Waaler (11/03/2011 11:34 am)

Geir Arne Waaler (11/03/2011 11:34 am)


Comments

There are no comments.