vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 4.x Add-ons (https://vborg.vbsupport.ru/forumdisplay.php?f=245)
-   -   vBulletin CMS Widgets - Widget: CMS Most Viewed Articles This Week (https://vborg.vbsupport.ru/showthread.php?t=240904)

reefland 04-20-2010 10:00 PM

Widget: CMS Most Viewed Articles This Week
 
1 Attachment(s)
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.

RedHacker 04-21-2010 06:58 AM

Please one screenshot or demo....?

reefland 04-21-2010 12:09 PM

PHP Code updated and screen shot attached.

blue6995 04-22-2010 07:54 AM

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

giorgino 04-22-2010 07:27 PM

Same for me. Empty

vbgser 04-22-2010 08:54 PM

Same for me

reefland 04-22-2010 09:57 PM

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.

blue6995 04-23-2010 04:54 AM

Quote:

Originally Posted by reefland (Post 2025624)
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

reefland 04-23-2010 06:18 PM

can you post your code for me?

blue6995 04-24-2010 04:45 AM

Quote:

Originally Posted by reefland (Post 2026096)
can you post your code for me?

It is working now, using the new code. Thanks


All times are GMT. The time now is 03:09 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01084 seconds
  • Memory Usage 1,747KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_code_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete