Hey, I need to create a Widget that will display the most view CMS articles in the sidebar. I've tried to use the code here
https://vborg.vbsupport.ru/showthread.php?t=240904
PHP Code:
ob_start();
// Current Week Most Viewed
$starttime = time() - (3600*24*7);
$mostpopularweek_get = vB::$db->query_read("
SELECT DISTINCT
ca.contentid,
cn.publishdate,
cn.nodeid,
cni.title,
cni.viewcount
FROM
".TABLE_PREFIX."cms_nodecategory cnc
JOIN
".TABLE_PREFIX."cms_node cn
ON
cnc.nodeid = cn.nodeid
JOIN
".TABLE_PREFIX."cms_article ca
ON
cn.contentid = ca.contentid
JOIN
".TABLE_PREFIX."cms_nodeinfo cni
ON
cn.nodeid = cni.nodeid
WHERE
cn.setpublish = 1
AND
cn.publishdate>'".$starttime."'
ORDER BY
cni.viewcount desc LIMIT 5
");
$output_bits = '';
while($article = vB::$db->fetch_array($mostpopularweek_get))
{
$output_bits .='<div class = "cms_widget_post_bit"><h4 class = "cms_widget_post_header">
<a href="content.php?r='.$article[nodeid].'">'.$article[title].'</a></h4></div>';
}
$output = $output_bits;
ob_end_clean();
, but it won't work, don't know if it's because I'm in 4.0.8 and that code also only allows you to show the most popular articles of the week, I need to show the Most Popular Articles of all time from the CMS.
Does anyone have some code for me, not a programmer at all, so I need something I can just cut and paste.
Please help.