Skip to content


Roller recent entries and comments

According to Marcel’s request in a recent comment – here’s how I hacked the list of recent entries and comments on my blog.
It is based on someone else’s work (I forgot who).

Create two new Recent Entries and Comments template pages.

Recent Entries template:


<ul>

#set( $tamerMap = $pageModel.getRecentWeblogEntries(100, null) )

#foreach( $tamerDay in $tamerMap.keySet() )

#set( $tamerEntries = $tamerMap.get($tamerDay) )

#foreach( $tamerEntry in $tamerEntries )

#set( $tamerLink = "$ctxPath/page/$userName/$page.link/$tamerEntry.anchor" )

<li><a href="$tamerLink" title="$tamerEntry.title">$tamerEntry.title</a></li>

#end

#end

</ul>

Recent Comments template:


#if($website.allowComments)

<ul>

#set( $tamerMap = $pageModel.getRecentWeblogEntries(25, nil) )

#foreach( $tamerDay in $tamerMap.keySet() )

#set( $tamerEntries = $tamerMap.get($tamerDay) )

#foreach( $tamerEntry in $tamerEntries )

#set( $sideCommentCount = $pageModel.getCommentCount($tamerEntry.Id))

#if( $sideCommentCount>0)

#set( $tamerLink = "$ctxPath/comments/$userName/$page.link/$tamerEntry.anchor" )

<li>[$sideCommentCount] <a href="$tamerLink">$tamerEntry.title</a>

</li>

#end

#end

#end

</ul>

#end

Include these pages in their respective locations in the main weblog template through #includePage(“<_templateName>”)

It’s just a quick hack, there are better ways to do it (macros), and the pervious method will limit the number of entries according to the page you’re on (try clicking any of the old entries and check the new list) – but these will work for most of the cases. Also, there’s this showRecentEntries macro definition that can be used – but I haven’t tried it. HTH.

Posted in Java.


One Response

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.

  1. Andres Almiray says

    Thanks for the tip Tamer, I was looking for something like this for my blog.