vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=251)
-   -   Show TOP Reputation Poster (https://vborg.vbsupport.ru/showthread.php?t=325691)

hollyboy 10-19-2017 10:49 PM

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?

MarkFL 10-20-2017 12:26 AM

1 Attachment(s)
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.

hollyboy 10-20-2017 02:42 PM

Quote:

Originally Posted by MarkFL (Post 2590545)
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

MarkFL 10-20-2017 03:15 PM

1 Attachment(s)
Quote:

Originally Posted by hollyboy (Post 2590566)
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>';



hollyboy 10-20-2017 03:21 PM

Quote:

Originally Posted by MarkFL (Post 2590567)
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!
https://vborg.vbsupport.ru/external/2017/10/4.jpg

MarkFL 10-20-2017 03:36 PM

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



hollyboy 10-20-2017 03:40 PM

Quote:

Originally Posted by MarkFL (Post 2590570)
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

MarkFL 10-20-2017 03:47 PM

Quote:

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

hollyboy 10-20-2017 03:51 PM

Quote:

Originally Posted by MarkFL (Post 2590572)
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

MarkFL 10-20-2017 03:56 PM

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


All times are GMT. The time now is 08:29 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.01276 seconds
  • Memory Usage 1,885KB
  • 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_php_printable
  • (7)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)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