Description:
Simply returns a list of the recent comments, useful for sites with low traffic. Based on recent_diaries by Steve Linberg.
Box Code:
my $content;
my $num_comments = 10;
my $trim_length = 45;
# Get the last $num_comments comments
my ($rv, $sth) = $S->db_select({
WHAT => 'U.nickname, C.subject, C.cid, C.sid',
FROM => 'comments C, users U',
WHERE => 'U.uid=C.uid',
ORDER_BY => 'date DESC',
LIMIT => $num_comments});
my $table = $sth->fetchall_arrayref;
my ($nickname, $subject, $cid, $sid);
for (@$table) {
($nickname, $subject, $cid, $sid) = @$_;
# trim the subject line if it is too long
if (length $subject > $trim_length) {
$title = substr($subject, 0, $trim_length);
$title =~ s/\s+\S+$//;
$title .= '...';
}
$content .= qq{
|dot| <A HREF="|rootdir|/comments/$sid/$cid#$cid">$subject</a> ($nickname)<BR>
};
}
# And return the content, like normal.
return $content;
|