Author Topic: REQ: mod that shows users who have given most comments  (Read 24855 times)

0 Members and 1 Guest are viewing this topic.

Offline eZz

  • Newbie
  • *
  • Posts: 17
    • View Profile
    • WALLPAPERS
REQ: mod that shows users who have given most comments
« on: October 03, 2005, 05:58:10 PM »
Is there any mod that show TOP users who have commented pics? Like i can put a putton for home site like " Tops users " or smthing?

Offline paburmester

  • Full Member
  • ***
  • Posts: 244
    • View Profile
Re: REQ: mod that shows users who have given most comments
« Reply #1 on: October 19, 2005, 10:03:59 PM »
im interested too

Offline beseech

  • Full Member
  • ***
  • Posts: 150
    • View Profile
Re: REQ: mod that shows users who have given most comments
« Reply #2 on: October 20, 2005, 01:54:33 AM »
sounds interesting ;)

Offline Loda

  • Sr. Member
  • ****
  • Posts: 353
    • View Profile
    • Fotosucht Schweiz
Re: REQ: mod that shows users who have given most comments
« Reply #3 on: October 20, 2005, 10:00:27 AM »
ok... here we go!

In includes/page_header.php
find
Code: [Select]
?>
Add before:
Code: [Select]
$sql = "SELECT user_comments, user_name, user_id FROM ".USERS_TABLE."
WHERE user_level >= '".USER."'
ORDER BY user_comments DESC
LIMIT 25";
$result = $site_db->query($sql);

while ($row = $site_db->fetch_array($result)) {
$last_action_user_list .= '<a href ="'.ROOT_PATH.'member.php?action=showprofile&user_id='.$row['user_id'].'"><b>'.$row['user_name'].'</b></a> <span class="smalltext">'.$row['user_comments'].'</span><br>';
}

$site_template->register_vars(array(
"user_comments_list" => $last_action_user_list,
));
unset($user_comments_list);

insert in templates/<your templates>/home.html
Code: [Select]
<table border="0" cellspacing="1" cellpadding="1" background="{template_url}/images/cat.gif" width="100%">
  <tr>
    <td height="20" background="{template_url}/images/back1.gif">
       <b>Top 25 commenter </b></td>
  </tr>
  <tr>
    <td class="row1">{user_comments_list}</td>
  </tr>
</table>
design is your part..
If u want to change from top 25 commenter to top 10 commenter just change this in page_header.php
Code: [Select]
LIMIT 25";to
Code: [Select]
LIMIT 10";

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: REQ: mod that shows users who have given most comments
« Reply #4 on: October 20, 2005, 02:36:56 PM »
strongly suggest not to use page_header.php unless you want display this information on EVERY page. Otherwise use the specific file where you want it be displayed (index.php) ;)
and another little fix:
Code: [Select]
$last_action_user_list .= '<a href ="'.ROOT_PATH.'member.php?action=showprofile&user_id='.$row['user_id'].'"><b>'.$row['user_name'].'</b></a> <span class="smalltext">'.$row['user_comments'].'</span><br>'; should be:
Code: [Select]
$last_action_user_list .= '<a href ="'.$site_sess->url(ROOT_PATH.'member.php?action=showprofile&user_id='.$row['user_id']).'"><b>'.$row['user_name'].'</b></a> <span class="smalltext">'.$row['user_comments'].'</span><br>';
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline paburmester

  • Full Member
  • ***
  • Posts: 244
    • View Profile
Re: REQ: mod that shows users who have given most comments
« Reply #5 on: October 27, 2005, 04:31:30 AM »
thanks! hey V@no where do i have to put it on my index.php??

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: REQ: mod that shows users who have given most comments
« Reply #6 on: October 27, 2005, 05:14:02 AM »
above
Code: [Select]
//-----------------------------------------------------
//--- Print Out ---------------------------------------
//-----------------------------------------------------
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline beseech

  • Full Member
  • ***
  • Posts: 150
    • View Profile
Re: REQ: mod that shows users who have given most comments
« Reply #7 on: October 27, 2005, 05:53:59 AM »
and about the inverse ? like who have receive more comments ?

;)

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: REQ: mod that shows users who have given most comments
« Reply #8 on: October 27, 2005, 06:09:22 AM »
Try this query:
Code: [Select]
$sql = "SELECT COUNT(c.comment_id) as user_comments, u.user_id, u.user_name
        FROM ".COMMENTS_TABLE." c
        LEFT JOIN ".IMAGES_TABLE." i ON (i.image_id = c.image_id)
        LEFT JOIN ".USERS_TABLE." u ON (u.user_id = i.user_id)
        WHERE i.image_active = 1 AND u.user_level >= '".USER."'
        GROUP BY u.user_id
        ORDER BY user_comments DESC
        LIMIT 25";
The number of comments will be available in $row['num'] variable.


[edit]
Query updated, no $row['num'] is needed (available) anymore
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline Stoleti

  • Hero Member
  • *****
  • Posts: 574
    • View Profile
Re: REQ: mod that shows users who have given most comments
« Reply #9 on: October 27, 2005, 09:26:40 PM »
i've tried the last code, and this show the same !! only change the usernames order , not the top of ( the user with more received comments " not the comments we've wrote, but how the user have received, allmost "popularity"


 8)

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: REQ: mod that shows users who have given most comments
« Reply #10 on: October 28, 2005, 12:11:49 AM »
And how do you check that it shows not correct users?
I've checked this query in phpmyadmin and it did showed me the correct users, the users who's picutures got in total the most comments. (well, obviosly I didn't go and count 1000+ comments for first few users, but it looked nearly right to me)
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline Stoleti

  • Hero Member
  • *****
  • Posts: 574
    • View Profile
Re: REQ: mod that shows users who have given most comments
« Reply #11 on: October 28, 2005, 12:22:08 AM »
i mean this show "how many user have wrote " and not " how many comments user have receive"  :wink:

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: REQ: mod that shows users who have given most comments
« Reply #12 on: October 28, 2005, 12:27:13 AM »
i mean this show "how many user have wrote " and not " how many comments user have receive" :wink:
The original code is showing "how many comments user wrote" and my query shows for "how many comments user have received from all his images"
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: REQ: mod that shows users who have given most comments
« Reply #13 on: October 28, 2005, 12:31:13 AM »
Ok, I think I see why you say so.
As I mentioned in my post, the number of comments will be avalable in $row['num'] so you will need made further changes in the code to show the value of that function ;)

I just updated my post, with new query, which will show proper names/numbers without needed change anything else in the code ;)
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline Stoleti

  • Hero Member
  • *****
  • Posts: 574
    • View Profile
Re: REQ: mod that shows users who have given most comments
« Reply #14 on: October 28, 2005, 01:51:24 AM »
thanks V@no  , now its working !!!!

 :mrgreen: