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: story_hit_box 1.00

Author: hurstdog [Info]

Description:

This displays the number of users that have viewed a particular story.

Box Code:

# story_hit_box
# NOTE: you might want to add an index to your
# viewed_stories table to make this run quite
# a bit faster, especially if your site is more
# than just a little busy
# mysql> create index sid_idx on viewed_stories (sid);
# ALSO, this doesn't cache yet, it will in the future.
# Shouldn't be a problem for small sites.
my $sid = $S->{CGI}->param('sid');

$sid = $S->{DBH}->quote($sid);

my ($rv,$sth) = $S->db_select({
FROM => 'viewed_stories',
WHAT => 'count(uid) as c',
WHERE => "sid = $sid"
});

my $count = 0;
if( $rv ) {
my $r = $sth->fetchrow_hashref;
$count = $r->{c};
}
$sth->finish();

my $content = qq[
  %%norm_font%%<b>$count</b> Scoop users have viewed this story.%%norm_font_end%%
];

return { content => $content };
Display: Sort:
Menu
· create account
· faq
· search
· report bugs
· Scoop Administrators Guide
· Scoop Box Exchange

Scoop Site Scroller: Get one yourself!
Smokedot
It's 4:19... do you know where your bong is?

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