[[PHCResults? &excludeIDs=`1,26,29` &limit=`1` &tpl=`test`]]
<p><i class="fa fa-eye"></i> [+phc.count+] for <a href="[~[+phc.pageID+]~]">[~[+id+]~]</a></p>
<?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; ?>
This question has been answered by breezer. See the first response.
<?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; ?>
<p><i class="fa fa-eye"></i> [+page_view_count+] <a href="[~[+id+]~]">[+pagetitle+]</a></p>