PDA

View Full Version : vBulletin CMS Widgets - Widget: Top 5 Posters this Month


MaryTheG(r)eek
12-21-2009, 10:00 PM
..............................................

nightbloom
12-22-2009, 02:58 PM
Worked beautifully on my site. Thanks!

fayax
12-23-2009, 06:48 AM
It is Excellent! and I love it!

btw any chance you can make a block out of this so we can also add it to the forums? :)

Forum Lover
12-23-2009, 10:53 AM
Tagged, will use it after upgrades on my site. BTW, can you read my siggy please? :p

bart6767
12-23-2009, 11:12 AM
Can this be made so it will open in same window other than a new window ?

MaryTheG(r)eek
12-23-2009, 01:47 PM
Can this be made so it will open in same window other than a new window ?

Yes, it can be done be modify the code. Just remove:

target="_blank"

from any link (those starting with "<a")

Maria

bart6767
12-23-2009, 05:57 PM
Yes, it can be done be modify the code. Just remove:

target="_blank"

from any link (those starting with "<a")

Maria

Thanks Maria

SonicGT
12-23-2009, 07:54 PM
Installed in my dev forum since im not prod yet with 4.0
The formatting for posts to user appears to be off though for me. I did remove the usergroup line in the query since in my dev site all the users are basically admin right now
See attached

https://vborg.vbsupport.ru/external/2009/12/38.jpg

Datenpapst
12-23-2009, 08:16 PM
Hi,
Is it possible to show the avatars of all users, the top 2 - 5 in a smaller size and also to add the online status, add as a friend and send a private message icon next to the name?

Boots
12-23-2009, 11:12 PM
Deathly slow query on a forum with a lot of posts.

Dr.osamA
12-23-2009, 11:40 PM
installed

Thanks Maria

MaryTheG(r)eek
12-24-2009, 09:43 AM
Deathly slow query on a forum with a lot of posts.

Just commenting in such a topic, says nothing more other than someone wants to appear smarty. Include in your post what do you think as optimised query, and also be more specific on your meaning of "lot of posts", so the users can compare it with their forum's posts. So "Lot of posts" means 1000, 10000, 100000 or what?

And don't forget the saying: "If you don't have something good to say, is better to keep your mouth close".


Thank you and Merry Christmas to you and to your family.
Maria

Boots
12-24-2009, 10:00 AM
Just commenting in such a topic, says nothing more other than someone wants to appear smarty. Include in your post what do you think as optimised query, and also be more specific on your meaning of "lot of posts", so the users can compare it with their forum's posts. So "Lot of posts" means 1000, 10000, 100000 or what?

In my case the forum has 2,162,154 posts and the query takes about 3-5 seconds. You could have clicked on the link to my forum to see the post total btw. I tried out the mod, found the query to be slow and removed it. I don't have time to optimize the query.


And don't forget the saying: "If you don't have something good to say, is better to keep your mouth close".


This doesn't apply in this case. People need to know the good and the bad when it comes to these mods. An inexperienced forum owner could cripple his forum from installing something without considering the negative effects it could have on performance.


Thank you and Merry Christmas to you and to your family.
Maria

Same to you :D

MaryTheG(r)eek
12-24-2009, 10:33 AM
In my case the forum has 2,162,154 posts and the query takes about 3-5 seconds. You could have clicked on the link to my forum to see the post total btw. I tried out the mod, found the query to be slow and removed it. I don't have time to optimize the query.

It's not about anount of posts my dear friend. It's about amount of users. The records in the parent table (in this case "Users"), is who takes more time and not the child table (in this case "Posts"). Simple because the child table is already indexed on userid, so the query stops running when userid is changing, unlike the parent table (users) where the query must go throughout all records.

In simple words: 1000 users X 2000 posts each, will take less time than 10000 users X 200 posts each, even if the total amount of posts is the same on both cases.

This doesn't apply in this case. People need to know the good and the bad when it comes to these mods. An inexperienced forum owner could cripple his forum from installing something without considering the negative effects it could have on performance.

Calorie wrote it somewhere. It's American saying, and yes I also disagree with it, but only in cases when someone says his opinion explaining it, just like you did in your second post.

Maria

grahamsmythe
12-26-2009, 01:08 AM
This is another nice little widget you've written.

Many thanks and keep up the good work!

grahamsmythe
12-26-2009, 01:34 AM
Rather than having just usergroup 2, is there any way of having it pick up usergroup 2 AND 10?

Id rather not remove line 17. As you say, Admins would always go to the top of the list.

kf4eok
12-26-2009, 02:03 AM
installed thanks

grahamsmythe
12-28-2009, 09:10 AM
Further to my other post about it recognising multiple usergroups, my installations doesn't seem to show users avatars, even though they DO have an avatar installed.

The top posters just has the default avatar showing.

steve1966
12-28-2009, 04:01 PM
great thanks

ccjc
12-29-2009, 05:28 AM
I dont see "Choose PHP Direct Execution as Widget's Type" in the widget creation page.

Am I missing something here?

MaryTheG(r)eek
12-29-2009, 10:48 AM
I dont see "Choose PHP Direct Execution as Widget's Type" in the widget creation page.

Am I missing something here?

This is a vBulletin issue, so you've to contact them for support. As you can see there are lot installation which means that this option exists. Actually is the 2nd from the end. Maybe your PHP version, your server type... don't know what to say.

Maria

Mikhailtech
01-02-2010, 03:00 AM
Not working on my site (check right side for the widget) :

http://www.pcshoptalk.com/

Any ideas?

kjpp
01-02-2010, 09:19 AM
It is posible to add this widget on forum site?

Regards
kjpp

MaryTheG(r)eek
01-02-2010, 10:05 AM
It is posible to add this widget on forum site?

Regards
kjpp

Only if someone else takes the code and change it to work with forumhome. I don't use to code touching forumhome.

Maria

tazattitude
01-02-2010, 01:26 PM
Rather than having just usergroup 2, is there any way of having it pick up usergroup 2 AND 10?

Id rather not remove line 17. As you say, Admins would always go to the top of the list.

Maria,
I would also like to do this. I'd like to add 2 more usergroups to the query, but NOT include the mods, the admin, and a couple other groups.

(WHERE usergroupid=2, 18, 19) ???


That would be great!

Thanks!

rbc
01-02-2010, 01:56 PM
Not working on my site (check right side for the widget) :
http://www.pcshoptalk.com/
Any ideas?

@ Mikhailtech
just works fine on your page, as fare as i can see :)

@ Maria
Thanks, i like it !

Mikhailtech
01-02-2010, 03:30 PM
You're right. I was checking posts for non-registered users, forgot this only checks that group by default.

@Maria ... is there any way to save/check this query after the month is over? Something like "last month's top posters". What would be the code syntax for that? I'm asking because I need to know the top posters for each month up to midnight and it's best to check that the following month.

allenewood
01-02-2010, 06:11 PM
Thank you!

Bergler
01-02-2010, 06:35 PM
Yes it works, but unless you can add more usergroups, I dont think it will work as good as it could. I went in to try and add other usergroups as suggested but I get a database error from where i added the usergroups! I tried it like this, (WHERE usergroupid=2, 18, 19) and like this (WHERE usergroupid=2 18 19) No work, just error on both.

SLY LS1
01-04-2010, 01:55 AM
My usernames and post count dont seem to line up...

Hmmm

Bergler
01-04-2010, 02:11 AM
Got this from another thread and this worked!!

Yes, sure. You can do it on 2 ways:

1.- Changing the "where" argument from WHERE usergroupid=2, to WHERE usergroupid=2 OR usergroupid=3 OR usergrooupid=7 . In this example we assume that you want to include members who belong to usergroups 2,3,7

2.- By using an array. At the top of the file add:

$grouparray = "2,3,7";
$groupids = explode(',',$grouparray);
Then change the "where" argument from WHERE usergroupid=2, to WHERE usergroupid IN ($groupids)

Maria

vividbreeze
01-05-2010, 06:52 PM
Hey, lets say it picks top 5 posters of Jan, what happens when Feb 1 hits? Will it start everyones count back down to ZERO so we can see who are the top posters EACH month so some ppl dont have a head star advantage?

thanks!

tazattitude
01-05-2010, 07:27 PM
Yes it restarts every month

MaryTheG(r)eek
01-11-2010, 03:19 PM
Due to lack of free time, I must decrease the time that I'm spending here for support. By having a long thread for each of my 16 mods, most often I'm bypassing questions. That's why for urgent questions please visit my site (http://www.microhellas.com/), where it's easier to support you, by having a thread per question.

Thank you
Maria

RedHacker
02-02-2010, 05:23 AM
Thanks but i have one problem.. If the avatar are big image not look fine..
How to fix....?

tazattitude
02-02-2010, 09:04 AM
Thanks but i have one problem.. If the avatar are big image not look fine..
How to fix....?

I would think that if you changed this line

<img border="0" src="'.$useravatar.'"><br />


to

<img border="0" width="100" src="'.$useravatar.'"><br />


this should take care of it.

RedHacker
02-02-2010, 09:11 AM
I would think that if you changed this line

<img border="0" src="'.$useravatar.'"><br />


to

<img border="0" width="100" src="'.$useravatar.'"><br />


this should take care of it.

Thanks very much...

RedHacker
02-09-2010, 09:38 AM
Problem with FF2 and show the numbers of posts

https://vborg.vbsupport.ru/external/2010/03/66.jpg

leeman
02-12-2010, 03:36 PM
How to fix this??

I changed limit from 5 to 10 and this poped in.

neudimenxion
03-10-2010, 05:47 AM
Problem with FF2 and show the numbers of posts

https://vborg.vbsupport.ru/external/2010/03/66.jpg

i'vw got the same problem too.

SLY LS1
04-27-2010, 12:06 PM
i'vw got the same problem too.



Me to

xabo
05-16-2010, 09:10 AM
Is there any way to ignore some usernames from the list?

TazDevilLooney
07-20-2010, 08:07 PM
This fixes the display problem with IE7

$posts = "Posts";
ob_start();
require_once('./includes/functions_user.php');
require_once('./includes/functions_bigthree.php');
// Current Week Top Posters
$starttime = mktime(0, 0, 0, date('n'), date('j'), date('Y')) - ((date('N')-1)*3600*24);
// Get Top Members for current week
$mostactiveweek_get = vB::$db->query_read("
SELECT ".TABLE_PREFIX."user.userid, ".TABLE_PREFIX."user.username, ".TABLE_PREFIX."user.usertitle,
COUNT(".TABLE_PREFIX."post.postid) AS postcount
FROM ".TABLE_PREFIX."user
LEFT JOIN ".TABLE_PREFIX."post
ON ".TABLE_PREFIX."post.userid=".TABLE_PREFIX."user.userid
AND dateline>'".$starttime."'
WHERE usergroupid=2

GROUP BY ".TABLE_PREFIX."user.userid
ORDER BY postcount DESC
LIMIT 5");
$topposter = true;
$output_bits = '';
while($user = vB::$db->fetch_array($mostactiveweek_get))
{
$percentage = round(($user[postcount]/$totalposts[postcount]) * 100);
if($topposter == true)
{
$avatarurl = fetch_avatar_url($user[userid]);
if (!$avatarurl) {
$useravatar = 'images/misc/avatar.png';
} else {
$useravatar = $avatarurl[0];
}
$output_bits .='<div align="center">
<img border="0" src="'.$useravatar.'"><br />
<a target="_self" href="member.php?u='.$user[userid].'">'.$user[username].'</a><br />
'.$user[usertitle].'<br />
'.$posts.': '.$user[postcount].'<br />
</div><hr />';
$topposter = false;
} else {
$output_bits .= '<a target="_self" href="member.php?u='.$user[userid].'">'.$user[username].'</a><div style="text-align: right;margin-top:-15px;">'.$user[postcount].'</div>';
}
}
$output = $output_bits;
ob_end_clean();


Enjoy TazDevilLooney

Yurified
07-30-2010, 03:09 PM
Awesome! Thanks xD
Is there a way that we can have this for forum sideblock?

cs28702
07-30-2010, 06:02 PM
installed, much appreciated. I just set my for 2 hours . If its slow, I dont care

TazDevilLooney
07-30-2010, 08:10 PM
Yes you sould be able to add it to a forum block. Try this....

AdminCP -> Forums and Moderators -> Forum Block Manager -> Add Block

Pick -> Custom HTML/PHP

Change title to what you want!
Content type -> PHP
Copy the code in to the Content Box

That sould be it....

TazDevilLooney

-> Update <-

Tested it my self and works fine enjoy.............

LuisManson
07-30-2010, 08:48 PM
i can make it as a forum and with MANY groups.... :(

Database error in vBulletin 4.0.5:

Invalid SQL:

SELECT user.userid, user.username, user.usertitle,
COUNT(post.postid) AS postcount
FROM user
LEFT JOIN post
ON post.userid=user.userid
AND dateline>'1277953200'
WHERE usergroupid IN (Array)
GROUP BY user.userid
ORDER BY postcount DESC
LIMIT 5;

MySQL Error : Unknown column 'Array' in 'where clause'
Error Number : 1054
Request Date : Friday, July 30th 2010 @ 06:47:57 PM
Error Date : Friday, July 30th 2010 @ 06:47:57 PM
Script : http://www.ccccc.com/forum.php
Referrer : http://www.cccc.com/admincp/index.php?do=head
IP Address : 201.253.32.50
Username : xxxxxx
Classname : vB_Database
MySQL Version : 5.0.90



Code used:


$grouparray = "2,28,23,26,24,25";
$groupids = explode(',',$grouparray);
$posts = "Posts";
ob_start();
require_once('./includes/functions_user.php');
require_once('./includes/functions_bigthree.php');
// Current Month Top Posters
$starttime = mktime(0, 0, 0, date('m'), 1, date('Y'));
// Get Top Members for current month
$mostactivemonth_get = vB::$db->query_read("
SELECT ".TABLE_PREFIX."user.userid, ".TABLE_PREFIX."user.username, ".TABLE_PREFIX."user.usertitle,
COUNT(".TABLE_PREFIX."post.postid) AS postcount
FROM ".TABLE_PREFIX."user
LEFT JOIN ".TABLE_PREFIX."post
ON ".TABLE_PREFIX."post.userid=".TABLE_PREFIX."user.userid
AND dateline>'".$starttime."'
WHERE usergroupid IN ($groupids)
GROUP BY ".TABLE_PREFIX."user.userid
ORDER BY postcount DESC
LIMIT 5");
$topposter = true;
$output_bits = '';
while($user = vB::$db->fetch_array($mostactivemonth_get))
{
$percentage = round(($user[postcount]/$totalposts[postcount]) * 100);
if($topposter == true)
{
$avatarurl = fetch_avatar_url($user[userid]);
if (!$avatarurl) {
$useravatar = 'images/misc/avatar.png';
} else {
$useravatar = $avatarurl[0];
}
$output_bits .='<div align="center">
<img border="0" src="'.$useravatar.'"><br />
<a target="_blank" href="member.php?u='.$user[userid].'">'.$user[username].'</a><br />
'.$user[usertitle].'<br />
'.$posts.':&nbsp;'.$user[postcount].'<br />
</div><hr />';
$topposter = false;
} else {
$output_bits .= '<a target="_blank" href="member.php?u='.$user[userid].'">'.$user[username].'</a><div style="float: right;">'.$user[postcount].'</div><br />';
}
}
$output = $output_bits;
ob_end_clean();

Yurified
07-31-2010, 02:44 PM
Yes you sould be able to add it to a forum block. Try this....

AdminCP -> Forums and Moderators -> Forum Block Manager -> Add Block

Pick -> Custom HTML/PHP

Change title to what you want!
Content type -> PHP
Copy the code in to the Content Box

That sould be it....

TazDevilLooney

-> Update <-

Tested it my self and works fine enjoy.............

I tried it and I have blank block :(

apokphp
08-01-2010, 01:38 AM
Yes you sould be able to add it to a forum block. Try this....

AdminCP -> Forums and Moderators -> Forum Block Manager -> Add Block

Pick -> Custom HTML/PHP

Change title to what you want!
Content type -> PHP
Copy the code in to the Content Box

That sould be it....

TazDevilLooney

-> Update <-

Tested it my self and works fine enjoy.............
Not sure what code you used...but it definitely isn't the op's listed code on a 4.0.5 board. Full of sql errors when you try to use it as a forum widget.

TazDevilLooney
08-08-2010, 11:29 PM
Yes you sould be able to add it to a forum block. Try this....

AdminCP -> Forums and Moderators -> Forum Block Manager -> Add Block

Pick -> Custom HTML/PHP

Change title to what you want!
Content type -> PHP
Copy the code in to the Content Box

That sould be it....

TazDevilLooney

-> Update <-

Tested it my self and works fine enjoy.............


I had no problem with this.

$posts = "Posts";
ob_start();
require_once('./includes/functions_user.php');
require_once('./includes/functions_bigthree.php');
// Current Week Top Posters
$starttime = mktime(0, 0, 0, date('n'), date('j'), date('Y')) - ((date('N')-1)*3600*24);
// Get Top Members for current week
$mostactiveweek_get = vB::$db->query_read("
SELECT ".TABLE_PREFIX."user.userid, ".TABLE_PREFIX."user.username, ".TABLE_PREFIX."user.usertitle,
COUNT(".TABLE_PREFIX."post.postid) AS postcount
FROM ".TABLE_PREFIX."user
LEFT JOIN ".TABLE_PREFIX."post
ON ".TABLE_PREFIX."post.userid=".TABLE_PREFIX."user.userid
AND dateline>'".$starttime."'
WHERE usergroupid=2

GROUP BY ".TABLE_PREFIX."user.userid
ORDER BY postcount DESC
LIMIT 5");
$topposter = true;
$output_bits = '';
while($user = vB::$db->fetch_array($mostactiveweek_get))
{
$percentage = round(($user[postcount]/$totalposts[postcount]) * 100);
if($topposter == true)
{
$avatarurl = fetch_avatar_url($user[userid]);
if (!$avatarurl) {
$useravatar = 'images/misc/avatar.png';
} else {
$useravatar = $avatarurl[0];
}
$output_bits .='<div align="center">
<img border="0" src="'.$useravatar.'"><br />
<a target="_self" href="member.php?u='.$user[userid].'">'.$user[username].'</a><br />
'.$user[usertitle].'<br />
'.$posts.': '.$user[postcount].'<br />
</div><hr />';
$topposter = false;
} else {
$output_bits .= '<a target="_self" href="member.php?u='.$user[userid].'">'.$user[username].'</a><div style="text-align: right;margin-top:-15px;">'.$user[postcount].'</div>';
}
}
$output = $output_bits;
ob_end_clean();



http://www.missiontcomputers.com/images/top.png


VB 4.0.5
Server Errors In Log = 0/None
:confused:

godtfred
08-11-2010, 10:09 AM
Installed works great, thanx