|
From: Jamie M. <ja...@mc...> - 2001-07-15 17:59:49
|
br...@me... (Brent Meshier) writes:
> Anyone have a hack for setheadertopics? I created the block
> "topic", yet still doesnt populate. I can't seem to figure out
> why it's not working. The sub does run, but the perl is a bit
> mistifying, especially:
>
> local $_ = $t;
> if (! /$_->{'tid'}/) {
>
> whats going on here? Where is $t set anyway?
Yeah it's way broken. It fails for like four different reasons;
several bugs in the algorithm and even if it could set the data it
would store it in the wrong place. Fortunately one of the bugs
keeps any of that code from ever getting run :)
If you're interested in making it work, check out a copy of fry
(the 2.2 release) and look at set_recent_topics.pl. Here's the
code; this will NOT port directly to 2.0 but it may help get
you started:
# For slashd
# "LIMIT 10" chosen arbitrarily, actually could be LIMIT 5 but doesn't
# hurt much to kick in some more in case the caller has been changed to
# want more.
sub getNewStoryTopic {
my($self) = @_;
my $story_table = getCurrentStatic('mysql_heap_table') ? 'story_heap' : 'stories';
my $sth = $self->sqlSelectMany(
"alttext, image, width, height, $story_table.tid",
"$story_table, topics",
"$story_table.tid=topics.tid AND displaystatus = 0
AND NOT FIND_IN_SET('delete_me', flags) AND time < NOW()",
"ORDER BY time DESC LIMIT 10"
);
return $sth;
}
sub {
my($virtual_user, $constants, $slashdb, $user) = @_;
my $sth = $slashdb->getNewStoryTopic();
my($cur_tid, $last_tid) = ('', '_not_a_topic_');
my $num_stories = 0;
my $html = '';
while (my $cur_story = $sth->fetchrow_hashref) {
my $cur_tid = $cur_story->{tid};
next if $cur_tid eq $last_tid; # don't show two in a row
$html .= <<EOT;
<TD><A HREF="$constants->{rootdir}/search.pl?topic=$cur_tid"><IMG
SRC="$constants->{imagedir}/topics/$cur_story->{image}"
WIDTH="$cur_story->{width}" HEIGHT="$cur_story->{height}"
BORDER="0" ALT="$cur_story->{alttext}"></A>
</TD>
EOT
last if ++$num_stories >= 5;
$last_tid = $cur_tid;
}
$sth->finish();
my $tpid = $slashdb->getTemplateByName("recentTopics", "tpid");
$slashdb->setTemplate($tpid, { template => $html });
};
--
Jamie McCarthy
ja...@mc...
|