Go Back   vb.org Archive > vBulletin Modifications > vBulletin 4.x Modifications > vBulletin 4.x Add-ons

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
  #2  
Old 04-21-2010, 06:58 AM
RedHacker RedHacker is offline
 
Join Date: Jan 2009
Posts: 878
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Please one screenshot or demo....?
Reply With Quote
  #3  
Old 04-21-2010, 12:09 PM
reefland reefland is offline
 
Join Date: Jan 2002
Posts: 68
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

PHP Code updated and screen shot attached.
Reply With Quote
  #4  
Old 04-22-2010, 07:54 AM
blue6995 blue6995 is offline
 
Join Date: Oct 2005
Posts: 207
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

When does it get populated with the names of the Articles? I have installed and carried out the instructions above, but the 'This Week's Most Popular Article Box is empty!

Thanks
Reply With Quote
  #5  
Old 04-22-2010, 07:27 PM
giorgino giorgino is offline
 
Join Date: Dec 2009
Posts: 122
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Same for me. Empty
Reply With Quote
  #6  
Old 04-22-2010, 08:54 PM
vbgser vbgser is offline
 
Join Date: Feb 2010
Posts: 7
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Same for me
Reply With Quote
  #7  
Old 04-22-2010, 09:57 PM
reefland reefland is offline
 
Join Date: Jan 2002
Posts: 68
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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();
Can one of you copy and paste this code and see if it populates? It should show immediately.
Reply With Quote
  #8  
Old 04-23-2010, 04:54 AM
blue6995 blue6995 is offline
 
Join Date: Oct 2005
Posts: 207
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by reefland View Post
Can one of you copy and paste this code and see if it populates? It should show immediately.
When I cut and paste that in I get the following error message at the top of the Home Page


Parse error: syntax error, unexpected T_STRING in /home2/rwfforum/public_html/vBulletin/packages/vbcms/widget/execphp.php(177) : eval()'d code on line 43
Reply With Quote
  #9  
Old 04-23-2010, 06:18 PM
reefland reefland is offline
 
Join Date: Jan 2002
Posts: 68
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

can you post your code for me?
Reply With Quote
  #10  
Old 04-24-2010, 04:45 AM
blue6995 blue6995 is offline
 
Join Date: Oct 2005
Posts: 207
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by reefland View Post
can you post your code for me?
It is working now, using the new code. Thanks
Reply With Quote
Reply

Thread Tools

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 09:59 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.04792 seconds
  • Memory Usage 2,314KB
  • Queries Executed 24 (?)
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
  • (2)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
  • (2)pagenav_pagelink
  • (10)post_thanks_box
  • (1)post_thanks_box_bit
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit
  • (10)post_thanks_postbit_info
  • (9)postbit
  • (1)postbit_attachment
  • (10)postbit_onlinestatus
  • (10)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