Description:
This box, when included in a /special page, renders a dynamic list of topics, with their images and links to the search page. Number of columns is variable (default 5)
Box Code:
# showtopics_box by Bill Huston, bhuston@vegdot.org
# v1.1 27 Feb 2003 added case insensitive sort
my $cols = shift @ARGS \|\| 5;
my ($rv, $sth) = $S->db_select({
WHAT => 'tid,image,alttext,width,height',
FROM => 'topics',
});
my $topics = $sth->fetchall_arrayref();
$sth->finish();
my $content = "<table border=0>";
my $images = $S->{UI}->{VARS}->{imagedir}.$S->{UI}->{VARS}->{topics};
my $col=0;
foreach my $topic (sort {lc($a->[0]) cmp lc($b->[0])} ( @{$topics})) {
my ($tid,$image,$alttext,$width,$height)= @$topic;
next if $tid =~ /^(all\|diary)$/;
if ($col) { $content .= "<td align=\"center\">"; } else {
$content .= "<tr><td align=\"center\">";}
$content .= "$topic->[0]";
$content .= qq{
<img src="$images/$image" alt="$alttext" width=$width height=$height><br><a href="/search/topic=$tid">$alttext</a>
};
$col = ($col+1) % $cols;
if ($col) {
$content .= "</td>"
} else {
$content .= "</td></tr>"
}
};
$content .= "</table>";
return{title=>"All Topics",content=>$content};
|