The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
Widget: CMS Most Viewed Articles This Week Details »» | |||||||||||||||||||||||||||||
Widget: CMS Most Viewed Articles This Week
Developer Last Online: Jan 2012
Most Viewed Articles This Week 1. Installation 1. Goto Admincp->vBullietin CMS->Widgets->Create New Widget 2. Choose PHP Direct Execution as Widget's Type 3. Insert a title. This Week's Most Popular for example. 4. Click Save 5. Click Configure on the right of the newly created widget. 6. Remove the default code that appears. 7. Copy and Paste the code in item 2 below. 8. Save 9. Goto Admincp->vBullietin CMS->Layout Manager 10. Add the Widget to your Layout 11. Click Save 2. PHP Code Code:
// 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 = ''; while($article = vB::$db->fetch_array($mostpopularweek_get)) { $output .='<div class = "cms_widget_post_bit"><h4 class="cms_widget_post_header"><a href="content.php?r='.$article[nodeid].'">'.$article[title].'</a> </h4></div>'; } 3. Change Log [Version 1.02 9-23-2010] Removed unnecessary ob*() calls. Changed output_bits to just output. [Version 1.01 4-21-2010] Fixed a bug show the correct URL was used for each article. Screenshots
Show Your Support
|
Благодарность от: | ||
romaszek |
Comments |
#62
|
||||
|
||||
It's not updating, Joe. something is wrong, it also displays nothing if i change the category id from 4 to 2. at category id 4 it shows only 7 articles, but doesn't show anything newly added to that category. i cleared the cache, set the times to 5 min, 20 min, 1 hr. nothing worked
here's my code Code:
$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.parentnode = 4 ORDER BY cn.publishdate desc LIMIT 20 "); $output = ''; while($article = vB::$db->fetch_array($mostpopularweek_get)) { $output .='<div class = "cms_widget_post_bit"><h4 class="cms_widget_post_header"><a href="content.php?r='.$article[nodeid].'">'.$article[title].'</a> </h4></div>'; } |
#63
|
||||
|
||||
You should NOT be using the category ID...
You need to view the database and use the parentnode number- They aren't the same number as the categoryid but on my forum they seemed to follow (be unique) with the categoryid. That is to say the categoryid might be 3 and the parentnode might be 5... categoryid 4 might have a parentnode of 7. Make sure you are checking the parennode from the database. If you want/need to pull from multiple parentnode numbers then change the line to: Code:
WHERE cn.parentnode IN (4,5,6) |
#64
|
||||
|
||||
That might be it, thanks but how do you get the parent node number off the database?
|
#65
|
||||
|
||||
You need to view the table cms_node table in something like phpmyadmin.
|
#66
|
|||
|
|||
Hi,
For this Widget, the PHP code for VBulletin CMS 4.1.12 on my portal is : Code:
ob_start(); // Current Week Most Viewed $starttime = time() - (3600*24*31); $mostpopularweekget = vB::$db->query_read(" select ".TABLE_PREFIX."cms_node.nodeid as nodeid, ".TABLE_PREFIX."cms_nodeinfo.title as title FROM ".TABLE_PREFIX."cms_node, ".TABLE_PREFIX."cms_nodeinfo where ".TABLE_PREFIX."cms_node.nodeid = ".TABLE_PREFIX."cms_nodeinfo.nodeid AND ".TABLE_PREFIX."cms_node.setpublish = 1 AND ".TABLE_PREFIX."cms_node.publishdate >'".$starttime."' ORDER BY ".TABLE_PREFIX."cms_nodeinfo.viewcount desc LIMIT 5; "); $outputbits = ''; while($article = vB::$db->fetch_array($mostpopularweekget)) { $outputbits .='<div class = "cms_widget_post_bit"><h4 class = "cms_widget_post_header"> <a rel="nofollow" href="content.php?r='.$article[nodeid].'">'.$article[title].'</a> → </h4> </div><br>'; } $output = $outputbits; ob_end_clean(); Thanks Best regards |
#67
|
|||
|
|||
Not working for me on v4.2 is there an update?
|
#68
|
|||
|
|||
Sorry but it is working correctly on V4.2
Using this code. PHP Code:
|
#69
|
|||
|
|||
Quote:
cms_widget_post_bit widget_post_bit and you'll get the lines you want |
#70
|
||||
|
||||
This thread is two years old.
|
#71
|
|||
|
|||
Yes, but there are a number of people that are still using the mod & others who are just now installing it and having similar issues. Sometimes after an upgrade you have to reinstall mods or start all over with new mods & you can't recall how you tweaked them to begin with.
Hehe, bumping an old mod with info is better than replying, "never mind - I fixed it" and then not explaining how. ;-) |
Thread Tools | |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|