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: 392
  • 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]

Thanks for having an interest with our portal. If you have any requests for features, have a look at the Feature Requests board.

Author Topic: Enhanced 'Latest Members" block with avatar  (Read 27398 times)

0 Members and 1 Guest are viewing this topic.

Offline rexall

  • Semi Newbie
  • *
  • Posts: 21
  • SMF Version: 2.0.10
Enhanced 'Latest Members" block with avatar
« on: August 31, 2015, 03:23:09 AM »
Mon 31 Aug 2015, 2:10 pm

Hiya ForumMates!

There is an off-the-shelf block "Latest Members" which does the job but is pretty anemic looking.  I wonder if it could be modified to display an avatar such as the "Top Poster" block does?

Whadaya think?

Rex

Ninja edit: got rid of the big "Request" in title, it's the right board to request, so no need to put it there as well :)
« Last Edit: August 31, 2015, 10:24:02 AM by ♦ Ninja ZX-10RR ♦ »

Offline ♦ Ninja ZX-10RR ♦

  • Spammer Hammer
  • Support
  • *
  • Posts: 1193
  • Gender: Male
  • Sniper Legends
    • Virtual Interactive Games Entertainment™
  • SMF Version: 2.0.13
  • SP Version: 2.3.6
  • Elkarte Version: 1.0.6
Re: [REQUEST] Enhanced 'Latest Members" block with avatar
« Reply #1 on: August 31, 2015, 04:44:31 AM »
Hi rexall,

I am just guessing here, but I am kind of sure it's not that way because newbies tend not to select an avatar. I don't think you want to see 3/5 default avatar images in there so it's most likely the reason why there isn't a setting for it.

EDIT: 2 quick hints! There is a typo in your forum URL from your profile (.colm instead of .com) and I cannot fix it because I don't have high enough privileges to do so. The other hint would be to update your SimplePortal to 2.3.6, since you are still running 2.3.5 on all of your linked sites but the last one.

Regards
« Last Edit: August 31, 2015, 05:46:08 AM by ♦ Ninja ZX-10RR ♦ »
Have you tried SimplePortal Documentation before asking? ;)
F.A.Q.  English Support  |  Blocks Support
Fancy Feature idea ?!  |  Blocks Requests
Themes & Graphics

? My job! ?No PMs for support unless it's a paid request. Thank you! :)#OpIsis

Offline rexall

  • Semi Newbie
  • *
  • Posts: 21
  • SMF Version: 2.0.10
Re: [REQUEST] Enhanced 'Latest Members" block with avatar
« Reply #2 on: August 31, 2015, 06:02:14 AM »
Thanks for the tips Ninja.  I fixed the URL, tks for catching the typo. Also, updating SP is on my list.

As to the new guys block and avatars, nice guess, but no cigar, I am afraid. :'(  In my screen shot of the Latest Members Block,  at least two of those new guys have avatars, so apparently, the block was just never coded to display the avatar.  Maybe your logic is correct, that new guys would might not tend to have avatars, and a placeholder would be ugly.  However, if they post, the placeholder next to their post is ugly a well.

Tks for the tips.

Rex

Offline ♦ Ninja ZX-10RR ♦

  • Spammer Hammer
  • Support
  • *
  • Posts: 1193
  • Gender: Male
  • Sniper Legends
    • Virtual Interactive Games Entertainment™
  • SMF Version: 2.0.13
  • SP Version: 2.3.6
  • Elkarte Version: 1.0.6
Re: [REQUEST] Enhanced 'Latest Members" block with avatar
« Reply #3 on: August 31, 2015, 06:38:25 AM »
Maybe this could help for that: http://custom.simplemachines.org/mods/index.php?mod=4064

That's surely interesting, it could be tricky to implement both that and what you said in the first place though.
Have you tried SimplePortal Documentation before asking? ;)
F.A.Q.  English Support  |  Blocks Support
Fancy Feature idea ?!  |  Blocks Requests
Themes & Graphics

? My job! ?No PMs for support unless it's a paid request. Thank you! :)#OpIsis

Offline ccbtimewiz

  • Hero Member
  • *****
  • Posts: 2185
  • Gender: Male
  • $("div.content:dd").hide();
  • SMF Version: None
  • SP Version: None
  • Elkarte Version: None
  • EhPortal Version: None
Re: Enhanced 'Latest Members" block with avatar
« Reply #4 on: August 31, 2015, 10:23:49 PM »
Open /Themes/default/css/portal.css

Find:
Code: [Select]
td.sp_top_poster, td.sp_staff, td.sp_blog, td.sp_articles
{
width: 45px;
}

Replace with:
Code: [Select]
td.sp_top_poster, td.sp_staff, td.sp_blog, td.sp_articles, td.sp_recent_member
{
width: 45px;
}

Find:
Code: [Select]
td.sp_staff_info
{
padding: 7px 0;
vertical-align: bottom;
}

Replace with:
Code: [Select]
td.sp_staff_info, td.sp_recent_member_info
{
padding: 7px 0;
vertical-align: bottom;
}

Open /Sources/PortalBlocks.php

Find:
Code: [Select]
function sp_latestMember($parameters, $id, $return_parameters = false)
{
global $smcFunc, $scripturl, $txt, $color_profile;

$block_parameters = array(
'limit' => 'int',
);

if ($return_parameters)
return $block_parameters;

$limit = !empty($parameters['limit']) ? (int) $parameters['limit'] : 5;

$request = $smcFunc['db_query']('','
SELECT id_member, real_name, date_registered
FROM {db_prefix}members
WHERE is_activated = {int:is_activated}
ORDER BY id_member DESC
LIMIT {int:limit}',
array(
'is_activated' => 1,
'limit' => $limit,
)
);
$members = array();
$colorids = array();
while ($row = $smcFunc['db_fetch_assoc']($request))
{
if (!empty($row['id_member']))
$colorids[$row['id_member']] = $row['id_member'];

$members[] = array(
'id' => $row['id_member'],
'name' => $row['real_name'],
'href' => $scripturl . '?action=profile;u=' . $row['id_member'],
'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>',
'date' => timeformat($row['date_registered'], '%d %b'),
);
}
$smcFunc['db_free_result']($request);

if (empty($members))
{
echo '
', $txt['error_sp_no_members_found'];
return;
}

if (!empty($colorids) && sp_loadColors($colorids) !== false)
{
foreach ($members as $k => $p)
{
if (!empty($color_profile[$p['id']]['link']))
$members[$k]['link'] = $color_profile[$p['id']]['link'];
}
}

echo '
<ul class="sp_list">';

foreach ($members as $member)
echo '
<li>', sp_embed_image('dot'), ' ', $member['link'], ' - ', $member['date'], '</li>';

echo '
</ul>';
}

Replace with:
Code: [Select]
function sp_latestMember($parameters, $id, $return_parameters = false)
{
global $smcFunc, $scripturl, $txt, $modSettings, $color_profile;

$block_parameters = array(
'limit' => 'int',
);

if ($return_parameters)
return $block_parameters;

$limit = !empty($parameters['limit']) ? (int) $parameters['limit'] : 5;

$request = $smcFunc['db_query']('','
SELECT m.id_member, m.real_name, m.date_registered, m.is_activated,
a.id_attach, a.attachment_type, a.filename
FROM {db_prefix}members as m
LEFT JOIN {db_prefix}attachments AS a ON (a.id_member = m.id_member)
WHERE m.is_activated = {int:is_activated}
ORDER BY m.id_member DESC
LIMIT {int:limit}',
array(
'is_activated' => 1,
'limit' => $limit,
)
);
$members = array();
$colorids = array();
while ($row = $smcFunc['db_fetch_assoc']($request))
{
if ($modSettings['avatar_action_too_large'] == 'option_html_resize' || $modSettings['avatar_action_too_large'] == 'option_js_resize')
{
$avatar_width = !empty($modSettings['avatar_max_width_external']) ? ' width="' . $modSettings['avatar_max_width_external'] . '"' : '';
$avatar_height = !empty($modSettings['avatar_max_height_external']) ? ' height="' . $modSettings['avatar_max_height_external'] . '"' : '';
}
else
{
$avatar_width = '';
$avatar_height = '';
}

if (!empty($row['id_member']))
$colorids[$row['id_member']] = $row['id_member'];

$members[] = array(
'id' => $row['id_member'],
'name' => $row['real_name'],
'href' => $scripturl . '?action=profile;u=' . $row['id_member'],
'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>',
'date' => timeformat($row['date_registered'], '%d %b'),
'avatar' => array(
'name' => $row['avatar'],
'image' => $row['avatar'] == '' ? ($row['id_attach'] > 0 ? '<img src="' . (empty($row['attachment_type']) ? $scripturl . '?action=dlattach;attach=' . $row['id_attach'] . ';type=avatar' : $modSettings['custom_avatar_url'] . '/' . $row['filename']) . '" alt="" class="avatar" border="0" />' : '') : (stristr($row['avatar'], 'http://') ? '<img src="' . $row['avatar'] . '"' . $avatar_width . $avatar_height . ' alt="" class="avatar" border="0" />' : '<img src="' . $modSettings['avatar_url'] . '/' . htmlspecialchars($row['avatar']) . '" alt="" class="avatar" border="0" />'),
'href' => $row['avatar'] == '' ? ($row['id_attach'] > 0 ? (empty($row['attachment_type']) ? $scripturl . '?action=dlattach;attach=' . $row['id_attach'] . ';type=avatar' : $modSettings['custom_avatar_url'] . '/' . $row['filename']) : '') : (stristr($row['avatar'], 'http://') ? $row['avatar'] : $modSettings['avatar_url'] . '/' . $row['avatar']),
'url' => $row['avatar'] == '' ? '' : (stristr($row['avatar'], 'http://') ? $row['avatar'] : $modSettings['avatar_url'] . '/' . $row['avatar'])
),
);
}
$smcFunc['db_free_result']($request);

if (empty($members))
{
echo '
', $txt['error_sp_no_members_found'];
return;
}

if (!empty($colorids) && sp_loadColors($colorids) !== false)
{
foreach ($members as $k => $p)
{
if (!empty($color_profile[$p['id']]['link']))
$members[$k]['link'] = $color_profile[$p['id']]['link'];
}
}

echo '
<table class="sp_fullwidth">';

foreach ($members as $member)
echo '
<tr>
<td class="sp_recent_member sp_center">', !empty($member['avatar']['href']) ? '
<a href="' . $scripturl . '?action=profile;u=' . $member['id'] . '"><img src="' . $member['avatar']['href'] . '" alt="' . $member['name'] . '" width="40" /></a>' : '', '
</td>
<td class="sp_recent_member_info">', $member['link'], '</td>
</tr>';

echo '
</table>';
}
« Last Edit: April 17, 2016, 07:49:31 AM by ♦ Ninja ZX-10RR ♦ »

Offline rexall

  • Semi Newbie
  • *
  • Posts: 21
  • SMF Version: 2.0.10
Re: Enhanced 'Latest Members" block with avatar
« Reply #5 on: September 02, 2015, 09:31:42 AM »
Hey, Sayaka!  Thanks a million!  I owe you one.

Offline ♦ Ninja ZX-10RR ♦

  • Spammer Hammer
  • Support
  • *
  • Posts: 1193
  • Gender: Male
  • Sniper Legends
    • Virtual Interactive Games Entertainment™
  • SMF Version: 2.0.13
  • SP Version: 2.3.6
  • Elkarte Version: 1.0.6
Re: Enhanced 'Latest Members" block with avatar
« Reply #6 on: September 02, 2015, 09:39:26 AM »
Well, since Sayaka took the time to have a proper look at it and code it, and since your reply seems to indicate it worked just fine I'll go ahead and mark this as solved :)
Many thanks to Sayaka, of course.

Regards
Have you tried SimplePortal Documentation before asking? ;)
F.A.Q.  English Support  |  Blocks Support
Fancy Feature idea ?!  |  Blocks Requests
Themes & Graphics

? My job! ?No PMs for support unless it's a paid request. Thank you! :)#OpIsis

Offline Ian M

  • Semi Newbie
  • *
  • Posts: 19
  • Gender: Male
  • SMF Version: 2.0.11
  • SP Version: 2.3.6
Re: Enhanced 'Latest Members" block with avatar
« Reply #7 on: April 15, 2016, 10:05:50 AM »
I know this thread has been closed but I'm just wondering if anyone has had success with it?

This is pretty much the final piece (hopefully) of my portal but I can't get it to actually do anything. Have entered the code in all the right places but it doesn't change the latest members block in any way, not even an error!

I'm on SP 2.3.6 and SMF 2.0.11 so maybe there's been a few changes since the script was written? The code has no effect in my custom theme (SMF Hacks Astonished), or the default theme.

If anyone could offer any pointers it would be much appreciated as I'd really like to get this to work.

Many thanks.

Offline ♦ Ninja ZX-10RR ♦

  • Spammer Hammer
  • Support
  • *
  • Posts: 1193
  • Gender: Male
  • Sniper Legends
    • Virtual Interactive Games Entertainment™
  • SMF Version: 2.0.13
  • SP Version: 2.3.6
  • Elkarte Version: 1.0.6
Re: Enhanced 'Latest Members" block with avatar
« Reply #8 on: April 15, 2016, 01:04:02 PM »
Hi and welcome to SimplePortal.

I'm pretty sure you edited the default css file, while you have a custom theme, and you have to edit the files in that theme folder, not default. Also, after doing css changes you *must* refresh your page by pressing Ctrl+F5 instead of just F5.

Regards
Have you tried SimplePortal Documentation before asking? ;)
F.A.Q.  English Support  |  Blocks Support
Fancy Feature idea ?!  |  Blocks Requests
Themes & Graphics

? My job! ?No PMs for support unless it's a paid request. Thank you! :)#OpIsis

Offline Ian M

  • Semi Newbie
  • *
  • Posts: 19
  • Gender: Male
  • SMF Version: 2.0.11
  • SP Version: 2.3.6
Re: Enhanced 'Latest Members" block with avatar
« Reply #9 on: April 15, 2016, 06:55:52 PM »
Hello and thank you for that. Have done all of the above before hand but still no effect! Have done every refresh and clearance known to man but still no change!!

I know you coding guys rely on every snippet to clear or solve a fault, but it simply isn't working which is very frustrating to say the least!

I've run it in Chrome, Firefox, IE, Android, iOS and even Edge with everything cleared but still no change, a simple error message would be nice then I could give you more to work with!

Will have another crack tomorrow and report back!!


Offline ♦ Ninja ZX-10RR ♦

  • Spammer Hammer
  • Support
  • *
  • Posts: 1193
  • Gender: Male
  • Sniper Legends
    • Virtual Interactive Games Entertainment™
  • SMF Version: 2.0.13
  • SP Version: 2.3.6
  • Elkarte Version: 1.0.6
Re: Enhanced 'Latest Members" block with avatar
« Reply #10 on: April 15, 2016, 07:07:42 PM »
Pretty sure you messed up somewhere, post the URL please, so I (or a fellow teammate) can check it.
Have you tried SimplePortal Documentation before asking? ;)
F.A.Q.  English Support  |  Blocks Support
Fancy Feature idea ?!  |  Blocks Requests
Themes & Graphics

? My job! ?No PMs for support unless it's a paid request. Thank you! :)#OpIsis

Offline Ian M

  • Semi Newbie
  • *
  • Posts: 19
  • Gender: Male
  • SMF Version: 2.0.11
  • SP Version: 2.3.6
Re: Enhanced 'Latest Members" block with avatar
« Reply #11 on: April 16, 2016, 07:26:35 AM »
Ok. Thanks for your reply. Will try and offer as much info as possible!!

xxx.providentagents.co.uk

Have started from scratch this morning and I'm getting the following error message in the "latest members" block
Quote
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.id_attach, a.attachment_type, a.filename
FROM smf_members as m
LEFT JOIN s' at line 2
File: /home/ianmcdonnell/public_html/forum/Sources/PortalBlocks.php
Line: 246

As a result I've removed the modified PortalBlocks.php and reverted back to the original which just shows the latest member list in the usual way.

I have left the modified code in /Themes/default/css/portal.css as this doesn't affect anything by being there.

Thanks!

\\ -> Possible spam ~ link removed
« Last Edit: April 16, 2016, 08:13:46 PM by Chen Zhen »

Offline ♦ Ninja ZX-10RR ♦

  • Spammer Hammer
  • Support
  • *
  • Posts: 1193
  • Gender: Male
  • Sniper Legends
    • Virtual Interactive Games Entertainment™
  • SMF Version: 2.0.13
  • SP Version: 2.3.6
  • Elkarte Version: 1.0.6
Re: Enhanced 'Latest Members" block with avatar
« Reply #12 on: April 16, 2016, 10:45:01 AM »
So it probably means you messed up the PortalBlocks.php, why did you re-edit it in the first place? We just had to see it to understand if it was just wrong css, but now you have to start all over again, and wasted both mine and your time :/
Have you tried SimplePortal Documentation before asking? ;)
F.A.Q.  English Support  |  Blocks Support
Fancy Feature idea ?!  |  Blocks Requests
Themes & Graphics

? My job! ?No PMs for support unless it's a paid request. Thank you! :)#OpIsis

Offline Ian M

  • Semi Newbie
  • *
  • Posts: 19
  • Gender: Male
  • SMF Version: 2.0.11
  • SP Version: 2.3.6
Re: Enhanced 'Latest Members" block with avatar
« Reply #13 on: April 16, 2016, 11:19:37 AM »
Sorry but I don't understand the "messed up PortalBlocks.php" remark and wasting mine and your time??

The point I was making was I put the replacement code into the PortalBlocks.php and it threw up the error as described.

I then had to revert back to the original PortalBlocks.php from back up in order to return the block to "as was" in the standard style.

And from that point was simply looking for any pointers as to the problem?

Offline ♦ Ninja ZX-10RR ♦

  • Spammer Hammer
  • Support
  • *
  • Posts: 1193
  • Gender: Male
  • Sniper Legends
    • Virtual Interactive Games Entertainment™
  • SMF Version: 2.0.13
  • SP Version: 2.3.6
  • Elkarte Version: 1.0.6
Re: Enhanced 'Latest Members" block with avatar
« Reply #14 on: April 16, 2016, 10:40:43 PM »
Simply put, if the block doesn't work, *you* messed up somewhere with the code edits, as it has been tested and confirmed to work (which is why I wanted to see it, to understand which one of the edits and help you to find the mistake).
You wasted my time and yours because nobody asked you to revert the block (actually, I had asked for a link to check and that's it), how can I see what's wrong if you don't let me see it?
I then had to revert back to the original PortalBlocks.php from back up in order to return the block to "as was" in the standard style.
No you didn't have to, you did that on your own - nobody can fix what they cannot see, especially on something that works for everyone else ;). And this made me and a fellow teammate think that you are just trying to spam your site link...? Apologize if it is not the case, though.
« Last Edit: April 16, 2016, 10:42:54 PM by ♦ Ninja ZX-10RR ♦ »
Have you tried SimplePortal Documentation before asking? ;)
F.A.Q.  English Support  |  Blocks Support
Fancy Feature idea ?!  |  Blocks Requests
Themes & Graphics

? My job! ?No PMs for support unless it's a paid request. Thank you! :)#OpIsis

Offline Chen Zhen

  • The Underdog
  • Operations Manager
  • *
  • Posts: 1350
  • Gender: Male
  • Kinesis
    • WebDev
  • SMF Version: 2.1
  • EhPortal Version: 1.22
Re: Enhanced 'Latest Members" block with avatar
« Reply #15 on: April 17, 2016, 01:07:23 AM »
The link was adjusted by me as I did not notice someone asked for it.
At first glance I can see that Maizono (ccbtimewiz) forgot a comma in the mysql syntax he posted.

.. ensure m.is_activated has a comma after it as shown below:
Code: [Select]
SELECT m.id_member, m.real_name, m.date_registered, m.is_activated,
a.id_attach, a.attachment_type, a.filename



Offline Ian M

  • Semi Newbie
  • *
  • Posts: 19
  • Gender: Male
  • SMF Version: 2.0.11
  • SP Version: 2.3.6
Re: Enhanced 'Latest Members" block with avatar
« Reply #16 on: April 17, 2016, 07:10:10 AM »
This is a great leap forward thank you.

The error has cleared and the block is now showing latest members. Unfortunately it isn't showing the avatars although the space is there for them. The only avatar that is showing is where a member joined with the social plug in via Facebook. Have cleared all caches etc.

As there's no error now I can leave it up so hopefully someone could take a look for me.

Should mention that all new members have avatars and I've also set up a test forum in the default smf theme and the same problem is there too.

Thanks in advance.

Quick edit as my link has been removed. www.providentagents.co.uk   Hope this is ok.

« Last Edit: April 17, 2016, 08:11:57 AM by Ian M »

Offline ♦ Ninja ZX-10RR ♦

  • Spammer Hammer
  • Support
  • *
  • Posts: 1193
  • Gender: Male
  • Sniper Legends
    • Virtual Interactive Games Entertainment™
  • SMF Version: 2.0.13
  • SP Version: 2.3.6
  • Elkarte Version: 1.0.6
Re: Enhanced 'Latest Members" block with avatar
« Reply #17 on: April 17, 2016, 07:50:25 AM »
Fixed code in Sayaka's post.
Have you tried SimplePortal Documentation before asking? ;)
F.A.Q.  English Support  |  Blocks Support
Fancy Feature idea ?!  |  Blocks Requests
Themes & Graphics

? My job! ?No PMs for support unless it's a paid request. Thank you! :)#OpIsis

Offline Ian M

  • Semi Newbie
  • *
  • Posts: 19
  • Gender: Male
  • SMF Version: 2.0.11
  • SP Version: 2.3.6
Re: Enhanced 'Latest Members" block with avatar
« Reply #18 on: April 17, 2016, 03:33:12 PM »
Just a little more information in case it helps

Members avatars do show in the block if they have uploaded their own or signed in with Facebook etc.

The code isn't showing avatars which members have selected from the default list in their profile settings.

Hope that's of use !!


Offline Chen Zhen

  • The Underdog
  • Operations Manager
  • *
  • Posts: 1350
  • Gender: Male
  • Kinesis
    • WebDev
  • SMF Version: 2.1
  • EhPortal Version: 1.22
Re: Enhanced 'Latest Members" block with avatar
« Reply #19 on: April 17, 2016, 10:56:41 PM »
Place the attached file into:
../avatars

Replace the entire sp_latestMember() function with the following:
Code: [Select]
function sp_latestMember($parameters, $id, $return_parameters = false)
{
global $smcFunc, $scripturl, $txt, $modSettings, $color_profile;

$block_parameters = array(
'limit' => 'int',
);

if ($return_parameters)
return $block_parameters;

$limit = !empty($parameters['limit']) ? (int) $parameters['limit'] : 5;

$request = $smcFunc['db_query']('','
SELECT m.id_member, m.real_name, m.date_registered, m.is_activated, m.avatar,
a.id_attach, a.attachment_type, a.filename
FROM {db_prefix}members as m
LEFT JOIN {db_prefix}attachments AS a ON (a.id_member = m.id_member)
WHERE m.is_activated = {int:is_activated}
ORDER BY m.id_member DESC
LIMIT {int:limit}',
array(
'is_activated' => 1,
'limit' => $limit,
)
);
$members = array();
$colorids = array();
while ($row = $smcFunc['db_fetch_assoc']($request))
{
$tihi = '';
if ($modSettings['avatar_action_too_large'] == 'option_html_resize' || $modSettings['avatar_action_too_large'] == 'option_js_resize')
{
$tihi = !empty($modSettings['avatar_max_width_external']) ? 'width:' . $modSettings['avatar_max_width_external'] . 'px;' : '';
$tihi .= !empty($modSettings['avatar_max_height_external']) ? 'height:' . $modSettings['avatar_max_height_external'] . 'px;' : '';
}
else
$tihi = 'width: 45px; height: 45px;';

if (!empty($row['id_member']))
$colorids[$row['id_member']] = $row['id_member'];

$avatar = $row['avatar'] == '' ? ($row['id_attach'] > 0 ? '<img src="' . (empty($row['attachment_type']) ? $scripturl . '?action=dlattach;attach=' . $row['id_attach'] . ';type=avatar' : $modSettings['custom_avatar_url'] . '/' . $row['filename']) . '" alt="" style="' . $tihi . ';border: 1px solid silver;" />' : '') : (stristr($row['avatar'], 'http://') ? '<img src="' . $row['avatar'] . '" alt="" class="avatar" style="' . $tihi . 'border: 1px solid silver;" />' : '<img src="' . $modSettings['avatar_url'] . '/' . $row['avatar'] . '" alt="" class="avatar" style="' . $tihi . 'border: 1px solid silver;" />');
$members[] = array(
'id' => $row['id_member'],
'name' => $row['real_name'],
'href' => $scripturl . '?action=profile;u=' . $row['id_member'],
'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>',
'date' => timeformat($row['date_registered'], '%d %b'),
'avatar' => array(
'name' => $row['avatar'],
'image' => !empty($avatar) ? $avatar : '<img src="' . $modSettings['avatar_url'] . '/no_avatar.gif" alt="" style="' . $tihi . '" />',
'href' => $row['avatar'] == '' ? ($row['id_attach'] > 0 ? (empty($row['attachment_type']) ? $scripturl . '?action=dlattach;attach=' . $row['id_attach'] . ';type=avatar' : $modSettings['custom_avatar_url'] . '/' . $row['filename']) : '') : (stristr($row['avatar'], 'http://') ? $row['avatar'] : $modSettings['avatar_url'] . '/' . $row['avatar']),
'url' => $row['avatar'] == '' ? '' : (stristr($row['avatar'], 'http://') ? $row['avatar'] : $modSettings['avatar_url'] . '/' . $row['avatar'])
),
);
}
$smcFunc['db_free_result']($request);

if (empty($members))
{
echo '
', $txt['error_sp_no_members_found'];
return;
}

if (!empty($colorids) && sp_loadColors($colorids) !== false)
{
foreach ($members as $k => $p)
{
if (!empty($color_profile[$p['id']]['link']))
$members[$k]['link'] = $color_profile[$p['id']]['link'];
}
}

echo '
<table class="sp_fullwidth">';

foreach ($members as $member)
echo '
<tr>
<td style="width: 45px;" class="sp_recent_member sp_center">
<a href="', $scripturl, '?action=profile;u=', $member['id'], '">', $member['avatar']['image'], '</a>
</td>
<td style="padding: 7px 7px;vertical-align: bottom;float: right;overflow: hidden;" class="sp_recent_member_info">', $member['link'], '</td>
</tr>';

echo '
</table>';
}