Scoop -- the swiss army chainsaw of content management
Front Page · Everything · News · Code · Help! · Wishlist · Project · Scoop Sites · Dev Notes · Latest CVS changes · Development Activities
Scoop Box Exchange - Show Box: top_hotlisted 1.00

Author: panner [Info]

Description:

Lists the top-ten stories to be hotlisted.

Box Code:

my ($rv,$sth) = $S->db_select({
FROM => 'stories, viewed_stories',
WHAT => 'stories.sid, title, COUNT(viewed_stories.sid) AS total',
WHERE => 'viewed_stories.sid = stories.sid AND hotlisted = 1',
GROUP_BY => 'viewed_stories.sid',
ORDER_BY => 'total DESC',
LIMIT => '10'
});

my @data;
my $where;
while (my @s = $sth->fetchrow_array) {
push(@data, \@s);
$where .= ' OR ' if $where;
$where .= 'sid = ' . $S->{DBH}->quote($s[0]);
}
$sth->finish;

($rv,$sth) = $S->db_select({
FROM => 'comments',
WHAT => 'sid, COUNT(sid)',
WHERE => $where,
GROUP_BY => 'sid'
});

my %counts;
while (my $s = $sth->fetchrow_arrayref) {
$counts{ $s->[0] } = $s->[1];
my $c = $counts{ $s->[0] };
}
$sth->finish;

my $out;
foreach my $d (@data) {
my $up = ($d->[2] == 1) ? '' : 's';
my $c = $counts{$d->[0]} || 0;
my $cp = ($c == 1) ? '' : 's';
$out .= qq~%%dot%% <a href="%%rootdir%%/story/$d->[0]">$d->[1]</a> ($c comment$cp) by $d->[2] user$up<br>~;
}

return $out;
Display: Sort:
rttr (none / 0) (#1)
by SCOOP44 on Mon Jul 22, 2019 at 01:20:44 AM PST

Major thankies for the post.Really looking forward to read more. Awesome. jual ready mix



Code (none / 0) (#2)
by Jesus399 on Wed Jan 15, 2020 at 03:58:31 AM PST

Well, the syntax is fine to use but there are a lot of things which we need to cover before jump into it. I find some great lectures from locus assignment reviews which is quite amazing in the form of learning new things in coding.



hi (none / 0) (#3)
by Nisha Knapp on Fri Oct 29, 2021 at 12:29:20 PM PST

You effectively manage your team and conduct specific task to have these incredible features and content. I would love to make this my guide. Thanks. 토토놀이터



Menu
· create account
· faq
· search
· report bugs
· Scoop Administrators Guide
· Scoop Box Exchange

Scoop Site Scroller: Get one yourself!
Scoop::Ads
Almost there...

Login
Make a new account
Username:
Password:

Hosted by ScoopHost.com Powered by Scoop
All trademarks and copyrights on this page are owned by their respective companies. Comments are owned by the Poster. The Rest © 1999 The Management

create account | faq | search