Welcome to Geeklog, Anonymous Tuesday, March 19 2024 @ 02:34 am EDT

Geeklog Forums

Stats for the last 10 articles


Status: offline

Dirk

Site Admin
Admin
Registered: 01/12/02
Posts: 13073
Location:Stuttgart, Germany
I've started blogging more regularly and wanted to know if my posts are actually being read. So I hacked stats.php to include a simple list of the last 10 articles and how many hits they got:

Text Formatted Code
// Views of the last 10 articles

$result = DB_query("SELECT sid,title,hits,UNIX_TIMESTAMP(date) AS day FROM {$_TABLES['stories']} WHERE (draft_flag = 0) AND (date <= NOW()) AND (Hits > 0)" . COM_getPermSQL ('AND') . $topicsql . " ORDER BY date DESC LIMIT 10");
$nrows  = DB_numRows($result);

if ($nrows > 0) {
    $header_arr = array(
        array('text' => $LANG10[8], 'field' => 'sid', 'header_class' => 'stats-header-title'),
        array('text' => $LANG09[17], 'field' => 'dt', 'header_class' => 'stats-header-title'),
        array('text' => $LANG10[9], 'field' => 'hits', 'header_class' => 'stats-header-count', 'field_class' => 'stats-list-count'),
    );
    $data_arr = array();
    $text_arr = array('has_menu'     =>  false,
                      'title'        => $LANG10[7],
    );

    for ($i = 0; $i < $nrows; $i++) {
        $A = DB_fetchArray($result);
        $A['title'] = stripslashes(str_replace('$','&#36;',$A['title']));
        $A['sid'] = COM_createLink($A['title'], COM_buildUrl($_CONF['site_url']
                  . "/article.php?story={$A['sid']}"));
        $A['dt']  = strftime("%x", $A['day']);
        $A['hits'] = COM_NumberFormat ($A['hits']);
        $data_arr[$i] = $A;
    }
    $display .= ADMIN_simpleList("", $header_arr, $text_arr, $data_arr);
} else {
    $display .= COM_startBlock($LANG10[7]);
    $display .= $LANG10[10];
    $display .= COM_endBlock();
}


This section goes before the "Top Ten Commented Stories" section in public_html/stats.php. It should work for the last couple of Geeklog releases but won't work with 2.0.0.

A similar hack for 2.0.0 should be easy to do. Just copy the section "Detailed story statistics", sort by date instead of by hits and add the new column.

bye, Dirk
 Quote

Status: offline

::Ben

Forum User
Full Member
Registered: 01/14/05
Posts: 1569
Location:la rochelle, France
A similar hack for 2.0.0 should be easy to do. Just copy the section "Detailed story statistics", sort by date instead of by hits and add the new column.


Thanks for the code and the "after sales service" Smile

Ben
I'm available to customise your themes or plugins for your Geeklog CMS
 Quote

All times are EDT. The time is now 02:34 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