Description:
This box takes a section and displays all the stories in that section in a FAQ-style format. This box is best deployed as an OP. It lists the titles of each story in a section as FAQ questions with named targets pointing ot each of the intro texts as the answer and links to the body text (using the displaystory OP) as answer 'details'.
Box Code:
my($content,$answers);
my $section=$S->{CGI}->param('section');
my $title=qq{FAQ: }.$S->{SECTION_DATA}->{$section}->{title};
my ($rv, $sth) = $S->db_select({
WHAT => 'sid, title,introtext,bodytext,commentstatus',
FROM => 'stories',
WHERE => qq{section = "$section" AND displaystatus >=0},
ORDER_BY => 'time DESC'});
# Add the link for each story
while (my $story = $sth->fetchrow_hashref()) {
$content .= qq{<li><A HREF="#$story->{sid}">$story->{title}</a><br>\n};
my $comments = $S->_commentcount($story->{sid});
$answers .= qq{<br><a name="$story->{sid}"></a><b>$story->{title}</b><br>\n
$story->{introtext}<br>
<table border=0 width=100%><tr><td align=left>|norm_font|};
if($story->{bodytext} ne ''){
$answers .= qq{<A HREF="|rootdir|/story/$story->{sid}">Details >></a>
};
if($story->{commentstatus}==0 \|\| ($story->{commentstatus}==1 && $comments)){
$answers .= qq{ ($comments Comments)};
}
} elsif($story->{commentstatus}==0 \|\| ($story->{commentstatus}==1 && $comments)){
$answers .= qq{<A HREF="|rootdir|/story/$story->{sid}">Comments >></a> ($comments)};
}
$answers .= qq{|end_norm_font|</td><td align=right>
|norm_font|[|end_norm_font|<a href="#top"
>|norm_font|Top|endnorm_font|</a>|norm_font|]|end_norm_font|
</td></tr></table><br>};
}
$content=qq{|norm_font|$content<br><br>$answers|end_norm_font|};
# And return the content, like normal.
return {content => $content, title => $title};
Announcement and Discussion
|