collapse

* Simple Portal Archived Forum

This is an Archive Forum.

The content in this forum may be out-of-date or have been superseded by newer information, and links in forum pages to other sites may not work.
This forum contains archives for future reference.

Visit our thread at Simple Machines Forum for current support.

SMF 2.1 users: EhPortal is a ported version of Simple Portal specifically designed for the SMF 2.1 branch.
Please visit web-develop.ca to download EhPortal and for its support.

* User Info

 
 
Welcome, Guest. Please login or register.

* Who's Online

  • Dot Guests: 735
  • Dot Hidden: 0
  • Dot Users: 0

There aren't any users online.

* Shoutbox

Refresh History
  • Shoutbox is not for support!
  • {OCS}MasterSeal: Yup, Still adore SP
    April 21, 2019, 07:08:06 PM
  • {OCS}MasterSeal: STILL love SP :)
    November 24, 2018, 05:05:50 AM
  • ♦ Ninja ZX-10RR ♦: <3 aegersz
    September 13, 2018, 03:36:09 PM
  • aegersz: I STILL <3 LOVE SimplePortal
    September 13, 2018, 07:11:39 AM
  • aegersz: o LOVE you guys - Simple Portal rocks !
    May 09, 2018, 05:18:59 AM
  • Chen Zhen: our apologies for the site being down.. please read server issues topic
    March 22, 2018, 05:32:38 AM
  • {OCS}MasterSeal: LOL PLEASE forget I just posted that. I found the answer in my own dang post back in 2015. lol sorry!
    July 04, 2017, 10:47:55 PM
  • {OCS}MasterSeal: I know this SB isnt' for support, but I just have a general question. Who would I contact to find out where SP stores its block info? Is it DB driven or files? I searched the site but came up with nothing. probably my fault any insight is appreciated.
    July 04, 2017, 10:43:36 PM
  • ♦ Ninja ZX-10RR ♦: Excuse me but what does Simpleportal have to deal with that?
    February 05, 2017, 08:21:14 PM
  • WhiteEagle: of course IMHO that site appears to be dead :(
    February 04, 2017, 01:08:05 PM
  • WhiteEagle: If I can get that, then I'll use it for that site...
    February 04, 2017, 01:07:35 PM
  • WhiteEagle: decided to not use SMF for any projects, unless I can get a copy of the premium version of the fanfiction archive plugin
    February 04, 2017, 01:06:54 PM
  • expertdecisions: cloudflare
    January 28, 2017, 08:01:47 AM
  • aegersz: SM release 2.0.13 !
    January 12, 2017, 06:00:13 AM
  • raffo: Tks Emanuele, even if I didn't understand the fix :D
    November 07, 2016, 02:01:20 AM
  • emanuele: [link]
    November 01, 2016, 12:43:50 PM
  • emanuele: raffo: the English support board is a good place. ;)
    November 01, 2016, 12:43:38 PM
  • raffo: Where can I find the fix for the shoutbox?
    November 01, 2016, 05:06:09 AM
  • {OCS}MasterSeal: To the SP team, I make a point to come here and thank you as much as possible for your work.  so again, THANK YOU!
    October 28, 2016, 10:38:05 AM
  • emanuele: That's indeed funny, the limit is present only in the patch and not the full install.
    October 22, 2016, 06:14:58 PM

* Recent Posts

Adding Forums Button to Nav bar by jirapon
[August 01, 2019, 09:07:12 AM]


Re: Board Icons by ♦ Ninja ZX-10RR ♦
[July 30, 2019, 04:03:41 PM]


MOVED: Czech translation???? by ♦ Ninja ZX-10RR ♦
[July 30, 2019, 03:04:51 PM]


Board Icons by jirapon
[July 30, 2019, 07:28:44 AM]


Re: Thankyou Simpleportal, by ♦ Ninja ZX-10RR ♦
[July 29, 2019, 09:41:29 AM]

If you're interested in helping other members with support requests, consider joining the Community Support Helpers group.

Author Topic: [SMF 2.0.2] Block 'top 5 most 'liked' members  (Read 16069 times)

0 Members and 1 Guest are viewing this topic.

Offline Kobar

  • Semi Newbie
  • *
  • Posts: 42
  • SMF Version: 2.0.2
  • SP Version: 2.3.5
[SMF 2.0.2] Block 'top 5 most 'liked' members
« on: October 05, 2012, 05:30:22 PM »
According to http://www.simplemachines.org/community/index.php?topic=436974.msg3416088#msg3416088

+members avatars

EDIT: Oops! I posted this in the wrong section.. Mod Request > Block Request.
« Last Edit: October 06, 2012, 04:02:24 AM by Kobar »

Offline Kobar

  • Semi Newbie
  • *
  • Posts: 42
  • SMF Version: 2.0.2
  • SP Version: 2.3.5
Re: [SMF 2.0.2] Block 'top 5 most 'liked' members
« Reply #1 on: October 10, 2012, 05:23:58 AM »
Anyone? :)

Offline hcfwesker

  • Semi Newbie
  • *
  • Posts: 43
  • SMF Version: 2.0.2
  • SP Version: 2.3.5
Re: [SMF 2.0.2] Block 'top 5 most 'liked' members
« Reply #2 on: October 22, 2012, 07:25:13 AM »
It can be done, since the Pro Version of SMF Likes adds a Top 10 Liked Members to the stats page.  But, it uses code from Sources/Stats.php and Stats.template.php to achieve this.  And, I'm not sure on how to combine the 2 into a php block added block.

Also, I doubt this would work for your site unless you have the Likes Pro MOD.

Offline hcfwesker

  • Semi Newbie
  • *
  • Posts: 43
  • SMF Version: 2.0.2
  • SP Version: 2.3.5
Re: [SMF 2.0.2] Block 'top 5 most 'liked' members
« Reply #3 on: October 22, 2012, 09:07:04 AM »
Just figured out how to do this, and it was pretty simple.  Preview pic attached below

You can preview it live, here on my site. (Left side 2nd Block)   http://www.smashdomain.net/index.php

I will share the edits.  But first, I need to ask NIBOGO's permission to share the edit, out of respect.  And ask him if it would even be compatible with Likes Lite version of the MOD.

Offline Kobar

  • Semi Newbie
  • *
  • Posts: 42
  • SMF Version: 2.0.2
  • SP Version: 2.3.5
Re: [SMF 2.0.2] Block 'top 5 most 'liked' members
« Reply #4 on: October 22, 2012, 11:25:39 AM »
ok

Offline hcfwesker

  • Semi Newbie
  • *
  • Posts: 43
  • SMF Version: 2.0.2
  • SP Version: 2.3.5
Re: [SMF 2.0.2] Block 'top 5 most 'liked' members
« Reply #5 on: October 22, 2012, 09:33:43 PM »

Here ya go.

Here are the 3 simple edits for this.

Sources/PortalBlocks.php

Find
Code: [Select]
'casino' => $txt['sp_topStatsMember_Casino'],
Add AFTER
Code: [Select]
'likes' => $txt['Likes'],
Find
Code: [Select]
'casino' => array(
'name' => 'Casino Cash',
'mod_id' => 1641,
'field' => 'mem.cash',
'order' => 'mem.cash',
'output_text' => '%cash%',
'enabled' => file_exists($sourcedir . 'casino/Casino.php'),
'error_msg' => $txt['sp_sashop_no_exist'],
),

Add AFTER
Code: [Select]
'likes' => array(
'name' => 'Likes',
'field' => 'mem.liked',
'order' => 'mem.liked',
'output_text' => '%liked% ' . $txt['Likes'],
'enabled' => file_exists($sourcedir . '/Likes.php'),
'error_msg' => $txt['sp_likes_no_exist'],
),

/languages/SPortal.english.php

Add Before the ?>  at the bottom of the file
Code: [Select]
$txt['Likes'] = 'Likes';
$txt['sp_likes_no_exist'] = 'Likes Pro MOD not found';


How To Create the Block

Now after you made the edits, when making a "New Block"  use the Block Option "Top Member Stats".  You'll now see the option to select Likes at the bottom of the drop down list of options.  Select the number of Top Liked members you'd like displayed (5), and rename the Block Title.

Enjoy!

Offline Kobar

  • Semi Newbie
  • *
  • Posts: 42
  • SMF Version: 2.0.2
  • SP Version: 2.3.5
Re: [SMF 2.0.2] Block 'top 5 most 'liked' members
« Reply #6 on: October 23, 2012, 12:12:57 PM »
Thanks!

But my error log get's full or:

Code: [Select]
website../forum/index.php?action=admin;area=portalblocks;sa=edit
Apply Filter: Only show the errors with the same message
8: A non well formed numeric value encountered
Apply Filter: Only show the errors from this file
File: /var/www/vhosts/website../httpdocs/forum/Sources/Subs.php
Line: 742

Offline hcfwesker

  • Semi Newbie
  • *
  • Posts: 43
  • SMF Version: 2.0.2
  • SP Version: 2.3.5
Re: [SMF 2.0.2] Block 'top 5 most 'liked' members
« Reply #7 on: October 23, 2012, 05:13:00 PM »
That's strange.  I'm using the same code and no errors in my error log from it.

How did you set your options when creating the box?  couls possibly come from you adding "Remove Inactive members from the List"  option.  that can't be used.

Attached is my settings.
« Last Edit: October 23, 2012, 05:26:39 PM by hcfwesker »

Offline hcfwesker

  • Semi Newbie
  • *
  • Posts: 43
  • SMF Version: 2.0.2
  • SP Version: 2.3.5
Re: [SMF 2.0.2] Block 'top 5 most 'liked' members
« Reply #8 on: October 23, 2012, 09:51:40 PM »
Also, I have a custom php block I'm working on, so you won't need to make any file edits.  But it only shows Avatars that are linked in profiles, not avatars uploaded as attachments.

If anyone could look at it and help me out.

Code: [Select]
global $smcFunc, $scripturl, $context, $txt;

$dbresult = $smcFunc['db_query']('', '
   SELECT real_name, avatar, liked, member_name, id_member
   FROM {db_prefix}members
   ORDER BY liked DESC
   LIMIT 5');
while ($row = $smcFunc['db_fetch_assoc']($dbresult))
{
   echo'<table width="100%"><tr width="100%"><td width="50"><img src="'.$row['avatar'].'" width="45" /></td><td><a href="'.$scripturl.'?action=profile;u='.$row['id_member'].'" />'.$row['real_name'].'</a><br>  '.$row['liked'].'  '.$txt['Likes'].' </td></tr></table>';
}
$smcFunc['db_free_result']($dbresult);



Offline Chen Zhen

  • The Underdog
  • Operations Manager
  • *
  • Posts: 1350
  • Gender: Male
  • Kinesis
    • WebDev
  • SMF Version: 2.1
  • EhPortal Version: 1.22
Re: [SMF 2.0.2] Block 'top 5 most 'liked' members
« Reply #9 on: October 23, 2012, 10:49:01 PM »
hcfwesker,

I do not have that like mod installed to test but try this for the user avatars:

Code: [Select]
global $smcFunc, $scripturl, $context, $txt, $boardurl;

$result = $smcFunc['db_query']('', '
   SELECT mem.real_name, mem.avatar, mem.liked, mem.member_name, mem.id_member, att.id_attach, att.filename
   FROM {db_prefix}members AS mem
   LEFT JOIN {db_prefix}attachments AS att ON (att.id_member = mem.id_member)
   ORDER BY liked DESC
   LIMIT 5');
while ($row = $smcFunc['db_fetch_assoc']($result))
{

if (!$row['avatar'] && !$row['filename'])
$avatar = $boardurl . '/avatars/noavatar.gif';
elseif (!$row['avatar'])
$avatar = $scripturl . '?action=dlattach;attach='.$row['id_attach'].';type=avatar';
elseif (substr($row['avatar'], 0, 4) != 'http')
$avatar = $boardurl .'/avatars/' . $row['avatar'];
else
$avatar = $row['avatar'];

echo'
<table width="100%">
<tr>
<td width="50"><img src="'.$avatar.'" style="width:45px;" /></td>
<td><a href="'.$scripturl.'?action=profile;u='.$row['id_member'].'" />'.$row['real_name'].'</a><br />  '.$row['liked'].'  '.$txt['Likes'].' </td>
</tr>
</table>';
}
$smcFunc['db_free_result']($result);

Edit -> Fixed block code.
« Last Edit: October 23, 2012, 11:16:35 PM by Underdog »

Offline hcfwesker

  • Semi Newbie
  • *
  • Posts: 43
  • SMF Version: 2.0.2
  • SP Version: 2.3.5
Re: [SMF 2.0.2] Block 'top 5 most 'liked' members
« Reply #10 on: October 23, 2012, 10:57:39 PM »
Thanx a lot.  I tried the code and it has the same behavior as my attempt.  Doesn't display attached avatars.

Offline hcfwesker

  • Semi Newbie
  • *
  • Posts: 43
  • SMF Version: 2.0.2
  • SP Version: 2.3.5
Re: [SMF 2.0.2] Block 'top 5 most 'liked' members
« Reply #11 on: October 23, 2012, 11:05:50 PM »
Think I got it! 

Had to change $user to $row  here
Code: [Select]
$avatar = $scripturl . '?action=dlattach;attach='.$user['id_attach'].';type=avatar';
thanx Underdog!  :)


Here;s the PHP custom Block code ( thanx to UnderDog for pro support)

Code: [Select]
global $smcFunc, $scripturl, $context, $txt, $boardurl;

$result = $smcFunc['db_query']('', '
   SELECT mem.real_name, mem.avatar, mem.liked, mem.member_name, mem.id_member, att.id_attach, att.filename
   FROM {db_prefix}members AS mem
   LEFT JOIN {db_prefix}attachments AS att ON (att.id_member = mem.id_member)
   ORDER BY liked DESC
   LIMIT 5');
while ($row = $smcFunc['db_fetch_assoc']($result))
{

if (!$row['avatar'] && !$row['filename'])
$avatar = $boardurl . '/avatars/noavatar.gif';
elseif (!$row['avatar'])
$avatar = $scripturl . '?action=dlattach;attach='.$row['id_attach'].';type=avatar';
elseif (substr($row['avatar'], 0, 4) != 'http')
$avatar = $boardurl .'/avatars/' . $row['avatar'];
else
$avatar = $row['avatar'];

echo'
<table width="100%">
<tr>
<td width="50"><img src="'.$avatar.'" style="width:45px;" /></td>
<td><a href="'.$scripturl.'?action=profile;u='.$row['id_member'].'" />'.$row['real_name'].'</a><br />  '.$row['liked'].'  '.$txt['Likes'].' </td>
</tr>
</table>';
}
$smcFunc['db_free_result']($result);
 


Offline Chen Zhen

  • The Underdog
  • Operations Manager
  • *
  • Posts: 1350
  • Gender: Male
  • Kinesis
    • WebDev
  • SMF Version: 2.1
  • EhPortal Version: 1.22
Re: [SMF 2.0.2] Block 'top 5 most 'liked' members
« Reply #12 on: October 23, 2012, 11:15:36 PM »
hcfwesker,

Yes I made a typo.. edited & corrected it.
Glad to see you got it functioning as you wish.



Offline Kobar

  • Semi Newbie
  • *
  • Posts: 42
  • SMF Version: 2.0.2
  • SP Version: 2.3.5
Re: [SMF 2.0.2] Block 'top 5 most 'liked' members
« Reply #13 on: October 24, 2012, 04:41:11 AM »
Thanks! But now I don't have the borders anymore around the avatars..

Code: [Select]
width="40" style="border: 1px solid #D8D8D8; padding: 5px; background: white;" />
EDIT:

I got it now. With 2px for border around the avatar it should be something like this:

Code: [Select]
global $smcFunc, $scripturl, $context, $txt, $boardurl;

$result = $smcFunc['db_query']('', '
   SELECT mem.real_name, mem.avatar, mem.liked, mem.member_name, mem.id_member, att.id_attach, att.filename
   FROM {db_prefix}members AS mem
   LEFT JOIN {db_prefix}attachments AS att ON (att.id_member = mem.id_member)
   ORDER BY liked DESC
   LIMIT 5');
while ($row = $smcFunc['db_fetch_assoc']($result))
{

if (!$row['avatar'] && !$row['filename'])
$avatar = $boardurl . '/avatars/noavatar.gif';
elseif (!$row['avatar'])
$avatar = $scripturl . '?action=dlattach;attach='.$row['id_attach'].';type=avatar';
elseif (substr($row['avatar'], 0, 4) != 'http')
$avatar = $boardurl .'/avatars/' . $row['avatar'];
else
$avatar = $row['avatar'];

echo'
<table width="100%">
<tr>
<td width="50"><img src="'.$avatar.'" width="40" style="border: 2px solid #D8D8D8; padding: 5px; background: white;"" /></td>
<td><a href="'.$scripturl.'?action=profile;u='.$row['id_member'].'" />'.$row['real_name'].'</a><br />  '.$row['liked'].'  '.$txt['Likes'].' </td>
</tr>
</table>';
}
$smcFunc['db_free_result']($result);
 

EDIT #2:
How is this custom mod compatible with the member color link?
« Last Edit: October 24, 2012, 07:11:35 AM by Kobar »

Offline Chen Zhen

  • The Underdog
  • Operations Manager
  • *
  • Posts: 1350
  • Gender: Male
  • Kinesis
    • WebDev
  • SMF Version: 2.1
  • EhPortal Version: 1.22
Re: [SMF 2.0.2] Block 'top 5 most 'liked' members
« Reply #14 on: October 24, 2012, 03:33:33 PM »
Kobar,

  This includes the member color & some of the code is corrected.

Code: [Select]
global $smcFunc, $scripturl, $context, $txt, $boardurl;

$result = $smcFunc['db_query']('', '
SELECT mem.real_name, mem.avatar, mem.liked, mem.member_name, mem.id_member, att.id_attach, att.filename, gp.online_color
FROM {db_prefix}members AS mem
LEFT JOIN {db_prefix}attachments AS att ON (att.id_member = mem.id_member)
LEFT JOIN {db_prefix}membergroups AS gp ON (gp.id_group = mem.id_group)
ORDER BY liked DESC
LIMIT 5');
while ($row = $smcFunc['db_fetch_assoc']($result))
{
if (!$row['avatar'] && !$row['filename'])
$avatar = $boardurl . '/avatars/noavatar.gif';
elseif (!$row['avatar'])
$avatar = $scripturl . '?action=dlattach;attach='.$row['id_attach'].';type=avatar';
elseif (substr($row['avatar'], 0, 4) != 'http')
$avatar = $boardurl .'/avatars/' . $row['avatar'];
else
$avatar = $row['avatar'];

if ((!empty($row['online_color'])) && $row['online_color'])
$name = '<span style="color:'.$row['online_color'].'">'.$row['real_name'].'</span>';
else
$name = '<span>' . $row['real_name']. '</span>';

echo'
<table width="100%">
<tr>
<td style="width:50%;"><img src="'.$avatar.'" style="width:40px;border: 2px solid #D8D8D8; padding: 5px; background: white;" alt="" title="'.$row['real_name'].'" /></td>
<td><a href="'.$scripturl.'?action=profile;u='.$row['id_member'].'">',$name,'</a><br />&nbsp;&nbsp;',$row['liked'],'&nbsp;&nbsp;',$txt['Likes'],'</td>
</tr>
</table>';
}
$smcFunc['db_free_result']($result);
« Last Edit: October 24, 2012, 03:40:10 PM by Underdog »

Offline Kobar

  • Semi Newbie
  • *
  • Posts: 42
  • SMF Version: 2.0.2
  • SP Version: 2.3.5
Re: [SMF 2.0.2] Block 'top 5 most 'liked' members
« Reply #15 on: October 24, 2012, 04:17:59 PM »
Thank you, it is. But now the text is centered..


Offline hcfwesker

  • Semi Newbie
  • *
  • Posts: 43
  • SMF Version: 2.0.2
  • SP Version: 2.3.5
Re: [SMF 2.0.2] Block 'top 5 most 'liked' members
« Reply #16 on: October 24, 2012, 06:36:00 PM »
I never needed any changes for the color links to show for members.  Possibly you're using the olf Member Color Link MOD.  Not sure if you know, but this MOD is an updated version that replaces any member link on the forum anywhere it is place.  http://custom.simplemachines.org/mods/index.php?mod=3067

It uses hooks so there are no file edits at all.

To fix the issue of the space between avatar and names.

Code: [Select]
<td style="width:50%;">
Change 50 to  something lower until it lines up how you want it.  maybe 40 or 45

« Last Edit: October 24, 2012, 06:46:11 PM by hcfwesker »

Offline Chen Zhen

  • The Underdog
  • Operations Manager
  • *
  • Posts: 1350
  • Gender: Male
  • Kinesis
    • WebDev
  • SMF Version: 2.1
  • EhPortal Version: 1.22
Re: [SMF 2.0.2] Block 'top 5 most 'liked' members
« Reply #17 on: October 24, 2012, 08:13:53 PM »
Kobar,

I put spaces in the html (... &nbsp;) as the block you posted had them as literal.
You can adjust the percentage for the first cell as hcfwesker suggested if you wish or you can change it to pixels (px) to match the avatar width (ie. 40px).

The block code below will align the text to the left without spaces between the avatar & text. If you want the blocks to look uniform in alignment of images & text compared to your top poster block, you can opt to adjust the top poster block code or perhaps adjust the style attributes you added to this block for the images.

Code: [Select]
global $smcFunc, $scripturl, $txt, $boardurl;

$result = $smcFunc['db_query']('', '
SELECT mem.real_name, mem.avatar, mem.liked, mem.member_name, mem.id_member, att.id_attach, att.filename, gp.online_color
FROM {db_prefix}members AS mem
LEFT JOIN {db_prefix}attachments AS att ON (att.id_member = mem.id_member)
LEFT JOIN {db_prefix}membergroups AS gp ON (gp.id_group = mem.id_group)
ORDER BY liked DESC
LIMIT 5');
while ($row = $smcFunc['db_fetch_assoc']($result))
{
if (!$row['avatar'] && !$row['filename'])
$avatar = $boardurl . '/avatars/noavatar.gif';
elseif (!$row['avatar'])
$avatar = $scripturl . '?action=dlattach;attach='.$row['id_attach'].';type=avatar';
elseif (substr($row['avatar'], 0, 4) != 'http')
$avatar = $boardurl .'/avatars/' . $row['avatar'];
else
$avatar = $row['avatar'];

if ((!empty($row['online_color'])) && $row['online_color'])
$name = '<span style="color:'.$row['online_color'].'">'.$row['real_name'].'</span>';
else
$name = '<span>' . $row['real_name']. '</span>';

$likes[] = array('avatar' => $avatar, 'real_name' => $row['real_name'], 'id_member' => $row['id_member'], 'liked' => $row['liked'], 'name' => $name);
}
$smcFunc['db_free_result']($result);
 
foreach ($likes as $like => $data)
echo'
<table width="100%">
<tr>
<td style="width:50px;"><img src="'.$data['avatar'].'" style="width:40px;border: 2px solid #D8D8D8; padding: 5px; background: white;" alt="" title="'.$data['real_name'].'" /></td>
<td style="text-align:left;"><a href="'.$scripturl.'?action=profile;u='.$data['id_member'].'">',$data['name'],'</a><br />',$data['liked'],'&nbsp',$txt['Likes'],'</td>
</tr>
</table>';


The image may appear larger when compared to the top posters block as in your image attachments, imo this is due to the extra style attributes you added for the image. Unless you have already adjusted your top poster source code.
 
Edit -> Display data after the db query.
« Last Edit: October 26, 2012, 12:53:39 AM by Underdog »

Offline hcfwesker

  • Semi Newbie
  • *
  • Posts: 43
  • SMF Version: 2.0.2
  • SP Version: 2.3.5
Re: [SMF 2.0.2] Block 'top 5 most 'liked' members
« Reply #18 on: October 24, 2012, 10:29:00 PM »
^ the man is too legit!

Also, I have one block my members have been requesting, and it's gonan be extensive cause its going to require at least 3 database table calls.  But im working on it now.  Not sure if you're interested but it'll display the most recent Liked Posts/Topics in a block. 

Offline Kobar

  • Semi Newbie
  • *
  • Posts: 42
  • SMF Version: 2.0.2
  • SP Version: 2.3.5
Re: [SMF 2.0.2] Block 'top 5 most 'liked' members
« Reply #19 on: October 25, 2012, 05:50:52 AM »
Thanks!! :D