Welcome to Geeklog, Anonymous Friday, April 19 2024 @ 04:18 pm EDT

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.

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.
 Quote

All times are EDT. The time is now 04:18 pm.

  • 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