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 |
#52
|
|||
|
|||
This is my edited code, it has bullet point at the start and seperated with lines:
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><hr>'; } $output = $outputbits; ob_end_clean(); |
#53
|
||||
|
||||
any ideas on getting it to pull x number of articles from a specific category instead of view count?
|
#54
|
||||
|
||||
Quote:
Then change the PHP code to: 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 = X ORDER BY cn.publishdate desc LIMIT Y "); $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>'; } X = the parentnode you want (this will be a number) Y = The max number of articles you want to pull from that parentnome (also a number.) That *should* work, I haven't tested it at all but it is basic MySQL. I didn't change any of the php code. |
Благодарность от: | ||
The Rocketeer |
#55
|
||||
|
||||
Quote:
Code:
Database error in vBulletin 4.1.12: Invalid SQL: SELECT DISTINCT ca.contentid, cn.publishdate, cn.nodeid, cni.title, cni.viewcount FROM cms_nodecategory cnc JOIN cms_node cn ON cnc.nodeid = cn.nodeid JOIN cms_article ca ON cn.contentid = ca.contentid JOIN cms_nodeinfo cni ON cn.nodeid = cni.nodeid WHERE cn.parentnode = 4 ORDER BY cni.publishdate desc LIMIT 5; MySQL Error : Unknown column 'cni.publishdate' in 'order clause' Error Number : 1054 Request Date : Thursday, May 17th 2012 @ 07:31:24 PM Error Date : Thursday, May 17th 2012 @ 07:31:25 PM Script : http://tomorrowsgaming.com/ Referrer : http://tomorrowsgaming.com/ IP Address : 122.61.154.171 Username : xxxxx Classname : vB_Database MySQL Version : 5.1.61-cll |
#56
|
||||
|
||||
Sorry it should be ORDER BY cn.publishdate desc... I will edit the original code I posted.
|
#57
|
||||
|
||||
Thanks Joe its working now! :up:
by the way, is there anyway to get the breadcrumbs working like the original one below? again thanks a lot, really appreciate it. |
#58
|
||||
|
||||
Sorry I don't know what you mean by breadcrumbs? To me breadcrumbs were what is under the navbar saying where you are in a forum, it wouldn't have anything to do with a widget... ?
|
#59
|
||||
|
||||
Sorry, I meant this https://vborg.vbsupport.ru/showpost....1&postcount=43
I wasn''t too sure what its called, breadcrumb separators maybe? :erm: See how the original has those small dots after each title, I think the original had these separators(?) but they disappeared or stopped working due to a vBulletin upgrade version incompatibility by the way, how often will it refresh and add more new articles added in the category to the list? currently I have set it to display 12, and have since added a few articles to the category, but it's only showing 7 and hasn't updated the list with the other articles yet. if i added the cache time to say a few hrs or even a few days (in mins) will it auto refresh every few day or so? |
#60
|
||||
|
||||
Hey
is it possible to change the url? <a href="content.php?r='.$article[nodeid].'"> The ID is not good for social-plugins. A foll url (/content/753-Sorcery) were better.... |
Благодарность от: | ||
The Rocketeer |
#61
|
||||
|
||||
Quote:
As for how often it refreshes there should be a cache time in the widget settings/configuration in the admin cp. It *should* refresh as often as you have it set. You can go to Admin CP -> Maintenance -> Clear System Cache to force the refresh. |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|