Go Back   vb.org Archive > vBulletin Modifications > vBulletin 4.x Modifications > vBulletin 4.x Add-ons
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
Widget: CMS Most Viewed Articles This Week Details »»
Widget: CMS Most Viewed Articles This Week
Version: 1.02, by reefland reefland is offline
Developer Last Online: Jan 2012 Show Printable Version Email this Page

Category: vBulletin CMS Widgets - Version: 4.0.6 Rating:
Released: 04-20-2010 Last Update: Never Installs: 83
Re-useable Code Translations  
No support by the author.

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

File Type: gif widget_screen_shot.gif (6.2 KB, 0 views)

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.
Благодарность от:
romaszek

Comments
  #22  
Old 07-24-2010, 08:36 PM
sticky sticky is offline
 
Join Date: Sep 2003
Posts: 934
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I'm on 4.0.2, doesn't work.
Reply With Quote
  #23  
Old 07-24-2010, 10:26 PM
BadgerDog BadgerDog is offline
 
Join Date: Oct 2006
Location: Toronto
Posts: 1,789
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Perhaps there's something else interfering?

Regards,
Badger
Reply With Quote
  #24  
Old 07-24-2010, 11:15 PM
vivamexico55 vivamexico55 is offline
 
Join Date: Apr 2005
Posts: 66
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Doesn't work on 4.04, only displays:

%24-%b-%2010
Reply With Quote
  #25  
Old 07-25-2010, 08:12 AM
mgcom's Avatar
mgcom mgcom is offline
 
Join Date: Apr 2009
Location: Dublin (Ireland)
Posts: 183
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

comes up blank on 4.0.5
Reply With Quote
  #26  
Old 08-07-2010, 07:24 PM
BryceW BryceW is offline
 
Join Date: Feb 2006
Posts: 22
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Second that it comes up blank on 4.0.5
Reply With Quote
  #27  
Old 09-23-2010, 12:25 PM
magmf magmf is offline
 
Join Date: Oct 2006
Posts: 32
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I changed the code and now it's working for me

Code:
ob_start();
  // Current Week Most Viewed
  $starttime = time() - (3600*24*7);
  $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 = vbcms_nodeinfo.nodeid AND ".TABLE_PREFIX."cms_node.setpublish = 1 AND ".TABLE_PREFIX."cms_nodeinfo.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>';
  }
  $output = $outputbits;
  ob_end_clean();
Please let me know if worked for you
Reply With Quote
  #28  
Old 09-23-2010, 02:31 PM
BadgerDog BadgerDog is offline
 
Join Date: Oct 2006
Location: Toronto
Posts: 1,789
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by magmf View Post
I changed the code and now it's working for me

Code:
ob_start();
  // Current Week Most Viewed
  $starttime = time() - (3600*24*7);
  $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 = vbcms_nodeinfo.nodeid AND ".TABLE_PREFIX."cms_node.setpublish = 1 AND ".TABLE_PREFIX."cms_nodeinfo.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>';
  }
  $output = $outputbits;
  ob_end_clean();
Please let me know if worked for you
Tried this and just ended up with a major SQL database error ....

Regards,
Badger
Reply With Quote
  #29  
Old 09-23-2010, 05:52 PM
magmf magmf is offline
 
Join Date: Oct 2006
Posts: 32
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

My fault


try this

Code:
ob_start();
  // Current Week Most Viewed
  $starttime = time() - (3600*24*7);
  $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 = vbcms_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>';
  }
  $output = $outputbits;
  ob_end_clean();
Reply With Quote
  #30  
Old 09-23-2010, 08:06 PM
BadgerDog BadgerDog is offline
 
Join Date: Oct 2006
Location: Toronto
Posts: 1,789
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Nope, that doesn't work either ... thanks anyway...

Quote:
Database error in vBulletin 4.0.4:

Invalid SQL:

select cms_node.nodeid as nodeid, cms_nodeinfo.title as title FROM cms_node, cms_nodeinfo where cms_node.nodeid = vbcms_nodeinfo.nodeid AND cms_node.setpublish = 1 AND cms_node.publishdate >'1284671090' ORDER BY cms_nodeinfo.viewcount desc LIMIT 5;;

MySQL Error : Unknown column 'vbcms_nodeinfo.nodeid' in 'where clause'
Error Number : 1054
Request Date : Thursday, September 23rd 2010 @ 05:04:50 PM
Error Date : Thursday, September 23rd 2010 @ 05:04:50 PM
Script : http://www.xxxxxx.com/content.php
Referrer : http://www.xxxxxx.com/index.php
IP Address : xx.xx.xxx.xxxx
Username : Tester
Classname : vB_Database
MySQL Version : 5.0.77
Reply With Quote
  #31  
Old 09-23-2010, 09:00 PM
magmf magmf is offline
 
Join Date: Oct 2006
Posts: 32
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

let me fix for you again.....


Code:
ob_start();
  // Current Week Most Viewed
  $starttime = time() - (3600*24*7);
  $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>';
  }
  $output = $outputbits;
  ob_end_clean();
Please if you get another error paste the error here for me so i can check again... But i think now will work was a small issue related to my table names...
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 10:02 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.05000 seconds
  • Memory Usage 2,340KB
  • Queries Executed 26 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (5)bbcode_code
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (4)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (11)post_thanks_box
  • (1)post_thanks_box_bit
  • (11)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit
  • (11)post_thanks_postbit_info
  • (10)postbit
  • (1)postbit_attachment
  • (11)postbit_onlinestatus
  • (11)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_attachment
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete