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)

dnk.it 04-05-2011 02:00 PM

this work great for vbulletin 4.1.1, thanks

Quote:

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



Anopheles 06-17-2011 10:17 PM

Works on 4.1.4 THANX!

romaszek 09-16-2011 07:04 AM

1 Attachment(s)
Hey.
Why there are no separators ?

Thanks.

doctorsexy 09-16-2011 08:06 AM

not working on my 4.1.5.... sql errors

jGas 10-04-2011 02:09 PM

It's not working on 4.1.6 .

This version of the code is working for me: https://vborg.vbsupport.ru/showpost....79&postcount=5

dang3rzon3 10-07-2011 06:17 PM

it is possible to add image's article?

mircea1st 11-30-2011 09:44 AM

I have this code:

ob_start();
// Current Week Most Viewed
$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 10;
");
$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();

Can we add a bullet at the begining of each article title ?
Thay are not separated at all .

sspeed 03-19-2012 07:37 PM

Sooo... I think I'm noticing a discrepancy... the link has it go to the article plus nodeid, for instance, on my site it's:

http://www.homenetworkenabled.com/content.php?r=129

The actual article address is:

http://www.homenetworkenabled.com/co...edia-appliance

Which includes the "SEO URL Alias"... both get there, but it appears to be making the viewcount inconsistent... Any way to include the SEO URL Alias so it goes to the correct URL?

sspeed 03-19-2012 09:02 PM

I think I've done what I've mentioned in the post above, who knows if it's right though... you can see it http://www.homenetworkenabled.com

PHP Code:

// Most popular articles
  
$starttime time() - (3600*24*18250);
  
$mostpopularweek_get vB::$db->query_read("
  SELECT DISTINCT
                 ca.contentid,
                 cn.publishdate,
                 cn.url,
                 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 6
     "
);
  
$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?'.$article[nodeid].'-'.$article[url].'">'.$article[title].'</a> ('.$article[viewcount].' views) </h4></div><br>';
  } 


sspeed 03-19-2012 09:09 PM

Quote:

Originally Posted by mircea1st (Post 2273336)

Can we add a bullet at the begining of each article title ?
Thay are not separated at all .

I noticed that as well, it was pretty gross looking, I just added a <br>, check out my site above and the code I posted..

Wizza 05-07-2012 06:02 PM

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


The Rocketeer 05-15-2012 09:33 AM

any ideas on getting it to pull x number of articles from a specific category instead of view count?

BirdOPrey5 05-17-2012 07:29 PM

Quote:

Originally Posted by The Rocketeer (Post 2329514)
any ideas on getting it to pull x number of articles from a specific category instead of view count?

I don't know about category but if you check the database you can see the column for parentnode in the cms_node table. On my site the parentnode seems to be numerical number consistent with a category...

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>';
  }

Look at the 2 lines in red-
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 05-18-2012 01:37 AM

Quote:

Originally Posted by BirdOPrey5 (Post 2330236)
I don't know about category but if you check the database you can see the column for parentnode in the cms_node table. On my site the parentnode seems to be numerical number consistent with a category...

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
  cni.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>';
  }

Look at the 2 lines in red-
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.

Thanks Joe.. :) But its throwing a Database error, something to do with the cni.publishdate I think :confused:

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


BirdOPrey5 05-18-2012 11:58 AM

Sorry it should be ORDER BY cn.publishdate desc... I will edit the original code I posted.

The Rocketeer 05-18-2012 02:43 PM

:) Thanks Joe its working now! :up:

by the way, is there anyway to get the breadcrumbs working like the original one below?
https://vborg.vbsupport.ru/attachmen...4&d=1271855308


again thanks a lot, really appreciate it. :)

BirdOPrey5 05-18-2012 03:25 PM

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... ?

The Rocketeer 05-18-2012 04:14 PM

Sorry, I meant this https://vborg.vbsupport.ru/showpost....1&postcount=43

https://vborg.vbsupport.ru/attachmen...1&d=1316160231https://vborg.vbsupport.ru/attachmen...2&d=1316160376

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 :confused:

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?

Kraxell 05-18-2012 04:46 PM

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

BirdOPrey5 05-18-2012 05:29 PM

Quote:

Originally Posted by The Rocketeer (Post 2330473)
Sorry, I meant this https://vborg.vbsupport.ru/showpost....1&postcount=43

https://vborg.vbsupport.ru/attachmen...1&d=1316160231https://vborg.vbsupport.ru/attachmen...2&d=1316160376

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 :confused:

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?

Those lines look like <hr> elements maybe... that's either a change you need to make to the template or a function of the style you are using- I'm not sure, styling isn't my strong point.

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.

The Rocketeer 05-19-2012 01:09 AM

It's not updating, Joe. something is wrong, it also displays nothing if i change the category id from 4 to 2. at category id 4 it shows only 7 articles, but doesn't show anything newly added to that category. i cleared the cache, set the times to 5 min, 20 min, 1 hr. nothing worked :confused:

here's my code

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 = 4
  ORDER BY
  cn.publishdate desc
  LIMIT 20
    ");
  $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>';
  }


BirdOPrey5 05-19-2012 10:17 AM

You should NOT be using the category ID...

You need to view the database and use the parentnode number- They aren't the same number as the categoryid but on my forum they seemed to follow (be unique) with the categoryid.

That is to say the categoryid might be 3 and the parentnode might be 5... categoryid 4 might have a parentnode of 7.

Make sure you are checking the parennode from the database.

If you want/need to pull from multiple parentnode numbers then change the line to:

Code:

WHERE
  cn.parentnode IN (4,5,6)

That would be where parentnode = 4, 5, or 6.

The Rocketeer 05-19-2012 11:40 AM

That might be it, thanks but how do you get the parent node number off the database?

BirdOPrey5 05-19-2012 03:08 PM

You need to view the table cms_node table in something like phpmyadmin.

DoumDoum5058 05-27-2012 04:09 PM

Hi,

For this Widget, the PHP code for VBulletin CMS 4.1.12 on my portal is :

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

Screenshout :

http://soudeurs.com/piece-jointe/dis...s_plus_lus.jpg

Thanks
Best regards

ar15dcm 07-05-2012 05:20 PM

Not working for me on v4.2 is there an update?

DoumDoum5058 11-18-2012 12:29 PM

Sorry but it is working correctly on V4.2
Using this code.
PHP 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 10;
     "
);
  
$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(); 

Thanks

Budget101 10-07-2014 06:03 PM

Quote:

Originally Posted by The Rocketeer (Post 2330473)

Just change the div class from cms_widget_post_bit to

cms_widget_post_bit widget_post_bit and you'll get the lines you want

ozzy47 10-07-2014 06:50 PM

This thread is two years old. :confused:

Budget101 10-09-2014 08:40 AM

Quote:

Originally Posted by ozzy47 (Post 2518056)
This thread is two years old. :confused:

Yes, but there are a number of people that are still using the mod & others who are just now installing it and having similar issues. Sometimes after an upgrade you have to reinstall mods or start all over with new mods & you can't recall how you tweaked them to begin with.

Hehe, bumping an old mod with info is better than replying, "never mind - I fixed it" and then not explaining how. ;-)

tbworld 10-09-2014 06:34 PM

We all appreciate the sharing, that is what makes the community. :)

concepts 10-29-2014 05:12 PM

Quote:

Originally Posted by tbworld (Post 2518274)
We all appreciate the sharing, that is what makes the community. :)

Exactly!!! and thanks for this mod!


All times are GMT. The time now is 12:54 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.01484 seconds
  • Memory Usage 1,866KB
  • 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
  • (2)bbcode_php_printable
  • (8)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
  • (32)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