Page 1 of 1
simple page counters using smarty.get
Posted: Fri Sep 19, 2014 3:50 pm
by uloloi
Code: Select all
{if isset($smarty.get.mact)}
{assign var=mod_action value=","|explode:$smarty.get.mact}
{assign var=mod_details
value=["articleid"=>$smarty.get.cntnt01articleid|default:null,
"returnid"=>$smarty.get.cntnt01returnid|default:$page_id,
"mact"=>$mod_action[0] ]}
{*<br> DEBUG: {$smarty.server.REQUEST_URI}
<br>$smarty.get.mact: <pre>{$mod_action|print_r}</pre>
<br>$mod_details: <pre>{$mod_details|print_r}</pre>*}
{/if}
{HitCounter opt='hits'}, {HitCounter opt='hosts'} {* Track pages *}
{if isset($entry) && isset($mod_details.articleid)}{HitCounter key1=$mod_details.mact key2=$mod_details.articleid}{/if} {* Track entries ID *}
Hitcounter do the job I just use this chunk into my template to record entries for each page of different modules such as News or CGBlog
Re: simple page counters using smarty.get
Posted: Fri Sep 19, 2014 6:45 pm
by uloloi
And with this:
Code: Select all
{stats_items} {* CALL UDT, return smarty var stats_items (array) *}
<pre>{$stats_items|print_r}</pre>
UDT track_items:
Code: Select all
$gCms = cmsms();
$db =& $gCms->GetDb();
$q = "SELECT key1,key2,count(*) as total FROM ".cms_db_prefix()."module_hitcounter GROUP BY key1,key2 ORDER BY total DESC";
$dbresult = $db->Execute( $q );
if( !$dbresult ) echo 'DB error: '. $db->ErrorMsg();
$row_dump = array();
while ($dbresult && $idrow = $dbresult->FetchRow())
{
$qrow = new StdClass;
$qrow->key1 = $idrow['key1'];
$qrow->key2 = $idrow['key2'];
$qrow->total = $idrow['total'];
$row_dump[] = $qrow;
}
$smarty->assign('stats_items',$row_dump);
Get page count of all items