Displaying most commented entries
From PixyWiki
Contents |
Overview
Display a list of the most commented entries on a blog. This can be done in a couple of ways; either by using the Macro to display a list of entries or by using the $model object.
Using the Macro
The macro is simple to include in your page templates and displays a list of the most commented entries and the number of comments of each entry. See the #showMostCommentedWeblogEntriesList documentation for details and an example.
Photoblog Example
For photoblogs, it can be useful to display a thumbnail image in-place of a text link. The following code shows an example of how to do this:
#set($comEntries = $model.weblog.getMostCommentedWeblogEntries(5) )
<div>
#foreach ($comEntry in $comEntries)
#set($image = $comEntry.image)
#set($thumb = $image.thumbSquare)
<span>
<a href="$url.entry($comEntry.anchor)" title="$comEntry.commentCount comments for $comEntry.title"><img src="$url.photo($thumb.path)" width="$thumb.width" height="$thumb.height" alt="#showImageAltTag($image)" /></a>
</span>
#end
</div>
Output
Using the demo blog the following is the output from the above code:


