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

giorgino 04-24-2010 12:50 PM

Not for me.
This is the code I've inserted:

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();

betts02 04-24-2010 11:43 PM

Any chance to make this work for a forum block ?

Cheers

g10net 05-28-2010 07:32 PM

it works,thanks. How can be done by daily?

reefland 05-30-2010 12:50 AM

g10net,

You could just change the $starttime to:
PHP Code:

 $starttime time() - (3600*24); 


uaewebmaster 05-30-2010 04:24 AM

Installed, Working 100%, Thanks :)

funmasti 05-30-2010 09:30 AM

can u make a XML? i mean installation file

g10net 05-31-2010 06:19 PM

Quote:

Originally Posted by reefland (Post 2045330)
g10net,

You could just change the $starttime to:
PHP Code:

 $starttime time() - (3600*24); 


does'nt work :(

reefland 05-31-2010 06:23 PM

Make sure that the starttime line looks just like the above post. Alternatively you can use:
PHP Code:

$starttime time() - 86400


reefland 05-31-2010 06:24 PM

Quote:

Originally Posted by funmasti (Post 2045410)
can u make a XML? i mean installation file

I am not aware of how to make an XML for a php direct execution widget.

BadgerDog 07-20-2010 11:25 AM

Installed on 4.0.4pl1 and works fine ... :)

Thanks ...

Regards,
Badger

sticky 07-24-2010 08:36 PM

I'm on 4.0.2, doesn't work.

BadgerDog 07-24-2010 10:26 PM

Perhaps there's something else interfering?

Regards,
Badger

vivamexico55 07-24-2010 11:15 PM

Doesn't work on 4.04, only displays:

%24-%b-%2010

mgcom 07-25-2010 08:12 AM

comes up blank on 4.0.5

BryceW 08-07-2010 07:24 PM

Second that it comes up blank on 4.0.5

magmf 09-23-2010 12:25 PM

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

BadgerDog 09-23-2010 02:31 PM

Quote:

Originally Posted by magmf (Post 2102229)
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

magmf 09-23-2010 05:52 PM

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();


BadgerDog 09-23-2010 08:06 PM

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

magmf 09-23-2010 09:00 PM

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... :)

BadgerDog 09-24-2010 01:39 PM

Quote:

Originally Posted by magmf (Post 2102444)
l
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... :)

Good news.. the last version did not generate any SQL errors and the widget displays, however, there's no data within the widget box?

Does it need to run for a while to generate history before it displays anything?

Thanks .. :)

Regards,
Badger

magmf 09-24-2010 03:50 PM

BadgerDog this will display the content of your articles from last 7 days in order of biggest page views number to less pageviews... if you dont have any article published in last 7 days this will return nothing... So my suggestion to you is publish a new article and see if this new article will appear on this widget.

Let me know if worked for you :)

BadgerDog 09-24-2010 04:08 PM

Ok, sorry, I misunderstood what it did ...

I thought it displayed "Most Viewed Articles This Week", meaning which of the several thousand articles we already have in our research library have been the most viewed by members this week.

I guess I'll have to un-install this as it's always going to be blank ... :)

Thanks for your efforts ...

Regards,
Badger

strudinox 09-24-2010 04:54 PM

Installed on 4.0.7 and working great!

Is there any way to make it pull articles from a specific section?

BioWaffen 10-07-2010 06:30 PM

Where can I exchange the name of the widget? (I want to use another one than "5 Most viewed Article" )

sticky 10-08-2010 06:13 AM

Quote:

Originally Posted by magmf (Post 2102444)
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... :)

Yes, this code worked for me! Any way to make the article text not bold like the title?

mgcom 11-07-2010 07:04 AM

how can i set this to be most viewed articles ever (not 7 days)

TheAquanox 12-09-2010 03:39 PM

Quote:

Originally Posted by mgcom (Post 2118935)
how can i set this to be most viewed articles ever (not 7 days)

How about changing

(3600*24*7)

by

(3600*24*18250)

I don't think your forum is older than 50 year lol.

Mark4865 02-05-2011 11:04 AM

Any way to include thumbnail images with this

project-Buckfas 02-19-2011 01:24 PM

1 Attachment(s)
This code works in 4.1.0

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();



All times are GMT. The time now is 07:13 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.01490 seconds
  • Memory Usage 1,849KB
  • 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
  • (8)bbcode_code_printable
  • (3)bbcode_php_printable
  • (9)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (40)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