Hey Everyone,
I have spent the better part of 2 days searching the forums, packages and add-ons page looking for a solution that works in Revo 2.x. I am a veteran with Evolution but this is my first install of Revolution.
I have been looking for a Top Viewed or Most Requested Pages listing snippet for a few days now. I read a lot of posts and articles that talk about the PageHits snippet in the package manager. It seems the in Evo someone named Susan came up with an snippet called Page Hits Counter Results and it would use the PageHits table data to create a list of resources based on the number of hits it had received.
The problem is I can't make it work in Revo apparently due to the changes in core processing.
Does anyone know if there is a new snippet for Revo that creates a "Most Viewed" list?
OR, does anyone know how to modify this code to work in Revo?
//Developed by David Bunker (bunk58) 28/08/08
//Requires the PageHitCounter 2.0 by Susan Otwell (http://modxcms.com/repository-upload.html?repotype=addition&resourceid=878)
//Create a new snippet named PHCResults
//Copy & Paste the code below into it
//The snippet takes 4 parameters:
//&excludeIDs => default = 0 , a comma seperated list of document ID's to exclude from the results (might be useful for 404 pages, Home page etc.)
//&limit => default = 5 , maximum number of results
//&table_prefix => default = modx_ , your database prefix if different to modx_
//&tpl => default = top_pages , name of template chunk for sidplaying the results
//Example call => [!PHCResults? &excludeIDs=`1,2,3` &limit=`10` &table_prefix=`custom_` &tpl=`your_tpl`!]
//The example template chunk below lists the four placeholders available
//Example template chunk =>
//<p>Total Hits = [+phc.count+] for <a href="[~[+phc.pageID+]~]" title="[+phc.title+]">[+phc.longtitle+]</a> - [+phc.description+]</p>
//Copy & Paste the above into a chunk and name it top_pages or create your own
//Here's the snippet code =>
$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.'pagehits`, `'.$table_prefix.'site_content` WHERE '.$table_prefix.'pagehits.resource_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;
Thanks for any help you can provide and I apologize if this has already been discussed many times, but if it has my search results have been fruitless.
Bryan