Welcome to Geeklog, Anonymous Saturday, December 21 2024 @ 11:11 am EST
Geeklog Forums
Here's the "Most Popular Articles Block"
Status: offline
DubiousChrisJ
Forum User
Regular Poster
Registered: 05/10/05
Posts: 114
Since I just added this back to my site and had the code up, I figured I would post it for y'all. One of the site regulars helped me cobble it together last year. Add this code to your lib-custom, and call the function in a PHP block.
{
global $_TABLES;
$result = DB_query("SELECT sid,title,hits FROM {$_TABLES['stories']}
WHERE (draft_flag = 0) AND (date <= NOW()) AND (hits > 0)"
. COM_getPermSQL ('AND') . " ORDER BY hits desc LIMIT 10");
$nrows = DB_numRows($result);
if( $nrows > 0 ){
$string = '';
$popular = array();
for( $i = 0; $i < $nrows; $i++ ){
$A = DB_fetchArray( $result );
$string .= $poplist . '<br>';
$popular[] = '<a href="' . COM_buildUrl( $_CONF['site_url']
. '/article.php?story=' . $A['sid'] ) . '">' . $A['title']
. '</a> (' . $A['hits'] . ')';
}
if( !empty( $popular )){
$poplist = COM_makeList( $popular, 'list-popular-stories' );
}
}
return $poplist;
}
Luhme summa dat GL.
Text Formatted Code
function phpblock_mostPopular(){
global $_TABLES;
$result = DB_query("SELECT sid,title,hits FROM {$_TABLES['stories']}
WHERE (draft_flag = 0) AND (date <= NOW()) AND (hits > 0)"
. COM_getPermSQL ('AND') . " ORDER BY hits desc LIMIT 10");
$nrows = DB_numRows($result);
if( $nrows > 0 ){
$string = '';
$popular = array();
for( $i = 0; $i < $nrows; $i++ ){
$A = DB_fetchArray( $result );
$string .= $poplist . '<br>';
$popular[] = '<a href="' . COM_buildUrl( $_CONF['site_url']
. '/article.php?story=' . $A['sid'] ) . '">' . $A['title']
. '</a> (' . $A['hits'] . ')';
}
if( !empty( $popular )){
$poplist = COM_makeList( $popular, 'list-popular-stories' );
}
}
return $poplist;
}
Luhme summa dat GL.
11
10
Quote
All times are EST. The time is now 11:11 am.
- Normal Topic
- Sticky Topic
- Locked Topic
- New Post
- Sticky Topic W/ New Post
- Locked Topic W/ New Post
- View Anonymous Posts
- Able to post
- Filtered HTML Allowed
- Censored Content