cogList the last 10 comments in the wiki
TypeSnippet
Category
Developed by

xwiki:XWiki.jurevert

Rating
0 Votes
LicenseGNU Lesser General Public License 2.1

Table of contents

Description

This snippet needs to be saved with programming rights. (It uses a privileged API - xwiki#search). If it is not saved with programming rights, the resulting page will not show up any result.

This snippet can have security side effects

Code

Using XWiki Syntax 1.0:

#set($sql="select obj.name, obj.number, propDateComment.value from BaseObject obj, DateProperty propDateComment where obj.className='XWiki.XWikiComments' and propDateComment.id.id=obj.id and propDateComment.name='date' order by propDateComment.value desc")
#set ($results = $xwiki.search($sql,10,0))
#if ($results.size() == 0)
#warning('No comment.')
#else
{table}
Page|Comment|Date|Author
#foreach ($row in $results)
  #foreach ($col in $row)
    #if ($velocityCount==1)
      #set($curDocFullName=$col)
    #elseif ($velocityCount==2)
      #set($objCommentNumber=$col)
    #end
  #end
 #set($curDoc=$xwiki.getDocument($curDocFullName))
 #set($curComment=$curDoc.getObject('XWiki.XWikiComments',$objCommentNumber))
[$curDocFullName]|$curComment.comment.replaceAll('\n','')|$curComment.date|$curComment.author
#end
{table}
#end
     

Get Connected