<![CDATA[ PageHitCounter - My Forums]]> https://forums.modx.com/thread/?thread=100557 <![CDATA[PageHitCounter]]> https://forums.modx.com/thread/100557/pagehitcounter#dis-post-543388
[[PHCResults? &excludeIDs=`1,26,29` &limit=`1` &tpl=`test`]]


Template "test" has this:

<p><i class="fa fa-eye"></i> [+phc.count+] for <a href="[~[+phc.pageID+]~]">[~[+id+]~]</a></p>


Now the UNIQUE page title is shown, however the corresponding UNIQUE COUNT is NOT. I tried adding [~[+id+]~] in front of [+phc.count+] but that did not work. Is it possible to get the corresponding unique page view count number next to my title?

UPDATE: Even though the correct page title is shown, when clicking the link it directs to another title (and its always the same title it directs to... sad - and that title is the one that has the MOST page-views, so the highest number of page views gets taken somehow always.

That problem is here in the PHP snippet:
<?php
$table_prefix = (isset($table_prefix)) ? $table_prefix : 'modx_';
$limit = (isset($limit)) ? $limit : 5;
$excludeIDs = (isset($excludeIDs)) ? $excludeIDs : '0';
$tpl = (isset($tpl)) ? $tpl : 'top_pages';
$output = '';
$sql = mysql_query('SELECT * FROM `'.$table_prefix.'page_hit_counter`, `'.$table_prefix.'site_content` WHERE '.$table_prefix.'page_hit_counter.page_id='.$table_prefix.'site_content.id AND '.$table_prefix.'site_content.id NOT IN('.$excludeIDs.')ORDER BY `page_count` DESC LIMIT '.$limit.'');
$resultArray = $modx->db->makeArray( $sql );
foreach($resultArray as $item)
{
$params['phc.count']=$item['page_count'];
$params['phc.pageID']=$item['page_id'];
$params['phc.title']=$item['pagetitle'];
$params['phc.longtitle']=$item['longtitle'];
$params['phc.description']=$item['description'];
$output.=$modx->parseChunk(''.$tpl.'', $params, '[+', '+]');
}
return $output;
?>


>>>>>>>>>>>> How to NOT have it sorted by page count, but just display by my ID????

http://modx.s3.amazonaws.com/extras/329/repo-2180.txt]]>
rbosos Jul 19, 2016, 08:24 AM https://forums.modx.com/thread/100557/pagehitcounter#dis-post-543388
<![CDATA[Re: PageHitCounter]]> https://forums.modx.com/thread/100557/pagehitcounter#dis-post-543401 breezer Jul 19, 2016, 04:05 PM https://forums.modx.com/thread/100557/pagehitcounter#dis-post-543401 <![CDATA[Re: PageHitCounter]]> https://forums.modx.com/thread/100557/pagehitcounter#dis-post-543396
I created the snippet ... page_view_count

and called it like this...
<p><i class="fa fa-eye"></i> [+page_view_count+] <a href="[~[+id+]~]">[+pagetitle+]</a></p>


But no number shows. If I use [!page_view_count!] then this shows frontend... [!page_view_count!] only.

I have Sotwell Page Hit Counter implemented... https://modx.com/extras/package/pagehitcounter and I can see the correct corresponding page views numbers in the module though.]]>
rbosos Jul 19, 2016, 11:53 AM https://forums.modx.com/thread/100557/pagehitcounter#dis-post-543396
<![CDATA[Re: PageHitCounter (Best Answer)]]> https://forums.modx.com/thread/100557/pagehitcounter#dis-post-543395
[!page_view_count!]

<?php
/* page_view_count snippet

* outputs the page hit count number for the page currently being viewed

*/
$output ='';
$count = $modx->db->getValue( 
             $modx->db->select( 'page_count', $modx->getFullTableName( 'page_hit_counter' ), 'page_id="'.$modx->documentObject['id'].'"' );
	
if( $count ) {
	$output =$count; 
}
return $output;
?>
]]>
breezer Jul 19, 2016, 11:25 AM https://forums.modx.com/thread/100557/pagehitcounter#dis-post-543395