2012-08-22, 19:15:51
michaellindahl Wrote:I have tried to modify the following to retrieve the hits on specific blog pages and from my testing this works:
Code:function return_hitcount_hits($slugOrFile) {
$post = @$_GET['post'];
if ($slugOrFile == 'blog' && $post) {
$hits = @file(GSDATAOTHERPATH . HITCOUNT_DIR . 'hits_' . preg_replace('/[^A-Za-z0-9\.-]+/','_',$slugOrFile).'-'.preg_replace('/[^A-Za-z0-9\.-]+/','_',$post) . '.txt');
} else {
$hits = @file(GSDATAOTHERPATH . HITCOUNT_DIR . 'hits_' . preg_replace('/[^A-Za-z0-9\.-]+/','_',$slugOrFile) . '.txt');
}
return $hits ? $hits[0] : 0;
}
You could also do this directly where you call return_hitcount_hits (e.g. in your template) without the need to modify the plugin, e.g.
Code:
$post = @$_GET['post'];
if (return_page_slug() == 'blog' && $post) {
$numHits = return_hitcount_hits(return_page_slug().'-'.$post);
} else {
$numHits = return_hitcount_hits(return_page_slug());
}
// do something with $numHits