Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 General Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 10-19-2017, 10:49 PM
hollyboy's Avatar
hollyboy hollyboy is offline
 
Join Date: Mar 2004
Posts: 318
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Show TOP Reputation Poster

Hi,
I would like to show the Top reputation poster on my board.
Preferably on the sidebar.
Is there a way?
Reply With Quote
  #2  
Old 10-20-2017, 12:26 AM
MarkFL's Avatar
MarkFL MarkFL is offline
 
Join Date: Feb 2014
Location: St. Augustine, FL
Posts: 3,853
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yes, you will need to create a new "Forum Block."

Follow:

AdminCP -> Forums & Moderators -> Forum Blocks Manager

At the bottom of the form, click "Add Block".

From the drop-down menu for "Select Block Type", choose "Custom HTML/PHP" then click "Continue".

You will be presented with a form for defining your new block. Give it a title, such as "Top 5 Reputations" and a description. I recommend caching the block for at least 60 minutes, this way the database need only be queried once an hour. Set the display order so that it shows where you desire in the sidebar.

For "Content Type" select "PHP".

And for the content, add the following code:

PHP Code:
global $vbulletin$db;
$max 5;
$output '<div class="restore"><ul>';

$rep_users $vbulletin->db->query_read("
    SELECT user.*
    FROM " 
TABLE_PREFIX "user AS user
    WHERE options & 1024
    AND usergroupid != 8
    ORDER BY reputation DESC
"
);

$rcount 0;

while (
$rep_user $db->fetch_array($rep_users) AND $rcount $max)
{
    
$output .= '<li>' repuser_link($rep_user) . ': ' $rep_user['reputation'] . ' Points</li>';
    
$rcount++;
}

$output .= '</ul></div>';

return 
$output;

function 
repuser_link($user)
{
    global 
$vbulletin;
    
$link 'member.php?do=getinfo&username=' $user['username'];

    if (
$user['displaygroupid'])
    {
        
$groupid $user['displaygroupid'];
    }
    else
    {
        
$groupid $user['usergroupid'];
    }

    
$open_tag $vbulletin->usergroupcache[$groupid]['opentag'];
    
$close_tag $vbulletin->usergroupcache[$groupid]['closetag'];
    
$title 'Visit ' $user['username'] . '\'s Profile';
    return 
'<a title="' $title '" href="' $link '">' $open_tag $user['username'] . $close_tag '</a>';

Change the line:

PHP Code:
$max 5
to match the number of users you wish to display.

Note: Users who have elected to hide their reputations will not be displayed. It only makes sense to honor this setting here. Also, banned users are excluded.

If you have any changes to the way the users are displayed, please let me know. The usernames are shown with their username markup, and link to their profiles.
Attached Images
File Type: png top_reps.png (5.3 KB, 0 views)
Reply With Quote
  #3  
Old 10-20-2017, 02:42 PM
hollyboy's Avatar
hollyboy hollyboy is offline
 
Join Date: Mar 2004
Posts: 318
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by MarkFL View Post
Yes, you will need to create a new "Forum Block."

Follow:

AdminCP -> Forums & Moderators -> Forum Blocks Manager

At the bottom of the form, click "Add Block".

From the drop-down menu for "Select Block Type", choose "Custom HTML/PHP" then click "Continue".

You will be presented with a form for defining your new block. Give it a title, such as "Top 5 Reputations" and a description. I recommend caching the block for at least 60 minutes, this way the database need only be queried once an hour. Set the display order so that it shows where you desire in the sidebar.

For "Content Type" select "PHP".

And for the content, add the following code:

PHP Code:
global $vbulletin$db;
$max 5;
$output '<div class="restore"><ul>';

$rep_users $vbulletin->db->query_read("
    SELECT user.*
    FROM " 
TABLE_PREFIX "user AS user
    WHERE options & 1024
    AND usergroupid != 8
    ORDER BY reputation DESC
"
);

$rcount 0;

while (
$rep_user $db->fetch_array($rep_users) AND $rcount $max)
{
    
$output .= '<li>' repuser_link($rep_user) . ': ' $rep_user['reputation'] . ' Points</li>';
    
$rcount++;
}

$output .= '</ul></div>';

return 
$output;

function 
repuser_link($user)
{
    global 
$vbulletin;
    
$link 'member.php?do=getinfo&username=' $user['username'];

    if (
$user['displaygroupid'])
    {
        
$groupid $user['displaygroupid'];
    }
    else
    {
        
$groupid $user['usergroupid'];
    }

    
$open_tag $vbulletin->usergroupcache[$groupid]['opentag'];
    
$close_tag $vbulletin->usergroupcache[$groupid]['closetag'];
    
$title 'Visit ' $user['username'] . '\'s Profile';
    return 
'<a title="' $title '" href="' $link '">' $open_tag $user['username'] . $close_tag '</a>';

Change the line:

PHP Code:
$max 5
to match the number of users you wish to display.

Note: Users who have elected to hide their reputations will not be displayed. It only makes sense to honor this setting here. Also, banned users are excluded.

If you have any changes to the way the users are displayed, please let me know. The usernames are shown with their username markup, and link to their profiles.
this is great!
can also avatar be displayed?
Also I want admin to be escluded from the list please
Reply With Quote
  #4  
Old 10-20-2017, 03:15 PM
MarkFL's Avatar
MarkFL MarkFL is offline
 
Join Date: Feb 2014
Location: St. Augustine, FL
Posts: 3,853
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by hollyboy View Post
this is great!
can also avatar be displayed?
Also I want admin to be escluded from the list please
Yes, change the content code to:

PHP Code:
global $vbulletin$db;
$max 5;
$output '<div class="restore"><ul style="margin-top: 0; margin-bottom: 0;">';

$rep_users $vbulletin->db->query_read("
    SELECT user.*
    FROM " 
TABLE_PREFIX "user AS user
    WHERE options & 1024
    AND usergroupid NOT IN (6,8)
    ORDER BY reputation DESC
"
);

$rcount 0;

while (
$rep_user $db->fetch_array($rep_users) AND $rcount $max)
{
    
$avatar_url fetch_avatar_url($rep_user['userid']);
    
$avatar $avatar_url[0];

    if (!
$avatar)
    {
        
$avatar $vbulletin->stylevars['imgdir_misc']['imagedir'] . '/unknown.gif';
    }

    
$output .= '<li><div style="display: inline-block; width: 20%; margin: 5px 0;"><img src="' $avatar '" style="vertical-align: middle; max-height: 40px;" /></div>' repuser_link($rep_user) . ': ' $rep_user['reputation'] . ' Points</li>';
    
$rcount++;
}

$output .= '</ul></div>';

return 
$output;

function 
repuser_link($user)
{
    global 
$vbulletin;
    
$link 'member.php?do=getinfo&username=' $user['username'];

    if (
$user['displaygroupid'])
    {
        
$groupid $user['displaygroupid'];
    }
    else
    {
        
$groupid $user['usergroupid'];
    }

    
$open_tag $vbulletin->usergroupcache[$groupid]['opentag'];
    
$close_tag $vbulletin->usergroupcache[$groupid]['closetag'];
    
$title 'Visit ' $user['username'] . '\'s Profile';
    return 
'<a title="' $title '" href="' $link '">' $open_tag $user['username'] . $close_tag '</a>';

Attached Images
File Type: png top_reps02.png (22.7 KB, 0 views)
Reply With Quote
  #5  
Old 10-20-2017, 03:21 PM
hollyboy's Avatar
hollyboy hollyboy is offline
 
Join Date: Mar 2004
Posts: 318
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by MarkFL View Post
Yes, change the content code to:

PHP Code:
global $vbulletin$db;
$max 5;
$output '<div class="restore"><ul style="margin-top: 0; margin-bottom: 0;">';

$rep_users $vbulletin->db->query_read("
    SELECT user.*
    FROM " 
TABLE_PREFIX "user AS user
    WHERE options & 1024
    AND usergroupid NOT IN (6,8)
    ORDER BY reputation DESC
"
);

$rcount 0;

while (
$rep_user $db->fetch_array($rep_users) AND $rcount $max)
{
    
$avatar_url fetch_avatar_url($rep_user['userid']);
    
$avatar $avatar_url[0];

    if (!
$avatar)
    {
        
$avatar $vbulletin->stylevars['imgdir_misc']['imagedir'] . '/unknown.gif';
    }

    
$output .= '<li><div style="display: inline-block; width: 20%; margin: 5px 0;"><img src="' $avatar '" style="vertical-align: middle; max-height: 40px;" /></div>' repuser_link($rep_user) . ': ' $rep_user['reputation'] . ' Points</li>';
    
$rcount++;
}

$output .= '</ul></div>';

return 
$output;

function 
repuser_link($user)
{
    global 
$vbulletin;
    
$link 'member.php?do=getinfo&username=' $user['username'];

    if (
$user['displaygroupid'])
    {
        
$groupid $user['displaygroupid'];
    }
    else
    {
        
$groupid $user['usergroupid'];
    }

    
$open_tag $vbulletin->usergroupcache[$groupid]['opentag'];
    
$close_tag $vbulletin->usergroupcache[$groupid]['closetag'];
    
$title 'Visit ' $user['username'] . '\'s Profile';
    return 
'<a title="' $title '" href="' $link '">' $open_tag $user['username'] . $close_tag '</a>';

awesome!
There is an avatar issue (check screenshot below) they should be all square
Also I would disable the bullet points
Thank you!
Reply With Quote
  #6  
Old 10-20-2017, 03:36 PM
MarkFL's Avatar
MarkFL MarkFL is offline
 
Join Date: Feb 2014
Location: St. Augustine, FL
Posts: 3,853
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

If you force the avatars to be square, then the aspect ratio of the images won't be preserved, and you will wind up with "squished" images. However, give this a try, and you'll see what I mean:

PHP Code:
global $vbulletin$db;
$max 5;
$output '<div class="restore">';

$rep_users $vbulletin->db->query_read("
    SELECT user.*
    FROM " 
TABLE_PREFIX "user AS user
    WHERE options & 1024
    AND usergroupid NOT IN (6,8)
    ORDER BY reputation DESC
"
);

$rcount 0;

while (
$rep_user $db->fetch_array($rep_users) AND $rcount $max)
{
    
$avatar_url fetch_avatar_url($rep_user['userid']);
    
$avatar $avatar_url[0];

    if (!
$avatar)
    {
        
$avatar $vbulletin->stylevars['imgdir_misc']['imagedir'] . '/unknown.gif';
    }

    
$output .= '<div style="margin: 5px 0;"><img src="' $avatar '" style="vertical-align: middle; width: 40px; height: 40px; margin-right: 0.25em" />' repuser_link($rep_user) . ': ' $rep_user['reputation'] . ' Points</div>';
    
$rcount++;
}

$output .= '</div>';

return 
$output;

function 
repuser_link($user)
{
    global 
$vbulletin;
    
$link 'member.php?do=getinfo&username=' $user['username'];

    if (
$user['displaygroupid'])
    {
        
$groupid $user['displaygroupid'];
    }
    else
    {
        
$groupid $user['usergroupid'];
    }

    
$open_tag $vbulletin->usergroupcache[$groupid]['opentag'];
    
$close_tag $vbulletin->usergroupcache[$groupid]['closetag'];
    
$title 'Visit ' $user['username'] . '\'s Profile';
    return 
'<a title="' $title '" href="' $link '">' $open_tag $user['username'] . $close_tag '</a>';

Reply With Quote
  #7  
Old 10-20-2017, 03:40 PM
hollyboy's Avatar
hollyboy hollyboy is offline
 
Join Date: Mar 2004
Posts: 318
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by MarkFL View Post
If you force the avatars to be square, then the aspect ratio of the images won't be preserved, and you will wind up with "squished" images. However, give this a try, and you'll see what I mean:

PHP Code:
global $vbulletin$db;
$max 5;
$output '<div class="restore">';

$rep_users $vbulletin->db->query_read("
    SELECT user.*
    FROM " 
TABLE_PREFIX "user AS user
    WHERE options & 1024
    AND usergroupid NOT IN (6,8)
    ORDER BY reputation DESC
"
);

$rcount 0;

while (
$rep_user $db->fetch_array($rep_users) AND $rcount $max)
{
    
$avatar_url fetch_avatar_url($rep_user['userid']);
    
$avatar $avatar_url[0];

    if (!
$avatar)
    {
        
$avatar $vbulletin->stylevars['imgdir_misc']['imagedir'] . '/unknown.gif';
    }

    
$output .= '<div style="margin: 5px 0;"><img src="' $avatar '" style="vertical-align: middle; width: 40px; height: 40px; margin-right: 0.25em" />' repuser_link($rep_user) . ': ' $rep_user['reputation'] . ' Points</div>';
    
$rcount++;
}

$output .= '</div>';

return 
$output;

function 
repuser_link($user)
{
    global 
$vbulletin;
    
$link 'member.php?do=getinfo&username=' $user['username'];

    if (
$user['displaygroupid'])
    {
        
$groupid $user['displaygroupid'];
    }
    else
    {
        
$groupid $user['usergroupid'];
    }

    
$open_tag $vbulletin->usergroupcache[$groupid]['opentag'];
    
$close_tag $vbulletin->usergroupcache[$groupid]['closetag'];
    
$title 'Visit ' $user['username'] . '\'s Profile';
    return 
'<a title="' $title '" href="' $link '">' $open_tag $user['username'] . $close_tag '</a>';

yes I see what you mean, but better than before. Thank you!
Do you think it can be also made by top poster of the week, month and so?
You should make it as an official mod
Thanks dude
Reply With Quote
  #8  
Old 10-20-2017, 03:47 PM
MarkFL's Avatar
MarkFL MarkFL is offline
 
Join Date: Feb 2014
Location: St. Augustine, FL
Posts: 3,853
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by hollyboy View Post
yes I see what you mean, but better than before. Thank you!
When I have more time, I will come up with a better solution for the avatars.

Quote:
Originally Posted by hollyboy View Post
Do you think it can be also made by top poster of the week, month and so?
You should make it as an official mod
Thanks dude
Yes, creating a forum block for the top posters for various time periods could be done...it's just a matter of coming up with the right db queries. Let me know exactly what you want, and I will see what I can do.
Reply With Quote
  #9  
Old 10-20-2017, 03:51 PM
hollyboy's Avatar
hollyboy hollyboy is offline
 
Join Date: Mar 2004
Posts: 318
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by MarkFL View Post
Let me know exactly what you want, and I will see what I can do.
Ok what I have in mind is the box that I have now on my board's sidebar , with 3 different tabs:

- top reputation of the week
- top reputation of the month
- all time top reputation
Reply With Quote
  #10  
Old 10-20-2017, 03:56 PM
MarkFL's Avatar
MarkFL MarkFL is offline
 
Join Date: Feb 2014
Location: St. Augustine, FL
Posts: 3,853
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I get a blank white page following the link you posted to your site. However, if you could create a mockup image of what you want this reputation block to ultimately look like, that would be a huge help in making certain I get what you want without having to make multiple changes.

Also, this would take some time, so it would be a while once I know exactly what you want before I would have the code ready.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 02:43 AM.


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.04756 seconds
  • Memory Usage 2,400KB
  • Queries Executed 12 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (8)bbcode_php
  • (7)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (2)postbit_attachment
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • postbit_attachment
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete