Description:
given a section name, ( like |BOX,section_headlines,news| it will show the latest headlines from them.
Box Code:
my $content;
# Call with one argument: section id
my $section = shift @ARGS;
my $count = shift @ARGS \|\| 6;
return unless ($section && $count);
# Get $count new stories from $section
my ($rv, $sth) = $S->db_select({
WHAT => 'sid, title, aid, tid, displaystatus',
FROM => 'stories',
WHERE => qq{section = '$section' AND displaystatus >= 0},
ORDER_BY => 'time DESC',
LIMIT => qq{$count}});
my $stories = $sth->fetchall_arrayref();
$sth->finish();
my $show = $S->{UI}->{VARS}->{show_new_comments};
foreach my $story (@{$stories}) {
my $num_new = $S->new_comments_since_last_seen($story->[0]) if ($show eq "hotlist" \|\| $show eq "all");
my $count = $S->_commentcount($story->[0]);
my $end_s = ($count == 1) ? '' : 's';
my $new_disp = ($num_new) ? "<b>$num_new</b>" : 0;
my $urlnick = $S->urlify($story->[2]);
$story->[2] =~ s/(\S{20})/$1- /g;
$story->[1] =~ s/(\S{20})/$1 /g;
my $b_start = ($story->[4]) ? '' : '<b>';
my $b_end = ($story->[4]) ? '' : '</b>';
my $topic = ($section eq 'Diary') ? qq{$story->[2]'s Diary} : $S->{TOPIC_DATA}->{$story->[3]}->{alttext};#'
my $topic_path = ($section eq 'Diary') ? "/user/$urlnick/diary" : qq{/search/?topic=$story->[3]};
$content .= qq{
$b_start<a href="|rootdir|/story/$story->[0]">$story->[1]</a>$b_end<br>
$count comment$end_s, $new_disp new<br>
<font size="-2">by <a href="|rootdir|/user/$urlnick">$story->[2]</a>, <a href="|rootdir|$topic_path">$topic</a></font><p>};
}
my $s_type = ($section eq 'Diary') ? 'diary' : 'story';
$content .= qq{
<a href="|rootdir|/search/?offset=0;old_count=$count;type=$s_type;section=$section;count=30;next=1">More $S->{SECTION_DATA}->{$section}->{title}...</a>
};
# Set title
my $title = qq{<a href="|rootdir|/section/$section"><font color="#FFFFFF">$S->{SECTION_DATA}->{$section}->{title}</font></a>};
return {title => $title, content => $content};
|