collapse collapse

* Archive Notice

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.

* User Info

 
 
Welcome, Guest. Please login or register.

* Who's Online

  • Dot Guests: 171
  • 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 11925 times)

0 Members and 1 Guest are viewing this topic.

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 #20 on: April 18, 2016, 02:56:20 AM »
Perfection is almost achieved thank you!!

At the risk of being a total pain in the backside there's just a couple of things left.

a) The avatars are showing at their full profile image size and are not resizing down as in the other portal blocks.

b) The member name text is aligning to the right of the block rather than to the left next to the avatar, again like in the other blocks.

Is this something that can be fixed without too much trouble as I've taken up a lot of peoples time already!!

Thank you.

Offline Chen Zhen

  • The Underdog
  • Operations Manager
  • *
  • Posts: 1351
  • Gender: Male
  • Kinesis
    • WebDev
  • SMF Version: 2.1
  • EhPortal Version: 1.22
Re: Enhanced 'Latest Members" block with avatar
« Reply #21 on: April 18, 2016, 06:00:01 AM »
Example shown below is using 30px dimensions

change this line to the preferred dimensions:
Code: [Select]
$tihi = 'width: 30px; height: 30px;';

change width of the cell to same as above, remove the float & increase padding left from the code below:
(changes used here are examples)
Code: [Select]
echo '
<tr>
<td style="width: 30px;" class="sp_recent_member sp_center">
<a href="', $scripturl, '?action=profile;u=', $member['id'], '">', $member['avatar']['image'], '</a>
</td>
<td style="padding-left: 8px;vertical-align: bottom;overflow: hidden;" class="sp_recent_member_info">', $member['link'], '</td>
</tr>';

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 #22 on: April 18, 2016, 07:08:14 AM »
Ok. Thank you for that. The text alignment is now correct, however the avatars are still remaining at their same size.

The avatars are 60px and I'm trying to reduce them to 45px. This is the actual code from my PortalBlocks.php

Code: [Select]
$tihi = 'width: 45px; height: 45px;';

Code: [Select]
<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-left: 7px;vertical-align: bottom;overflow: hidden;" class="sp_recent_member_info">', $member['link'], '</td>
</tr>';

To be honest I'll take it how it is, but I'm just wondering if it's something that's in front of me!!
« Last Edit: April 18, 2016, 07:10:22 AM by Ian M »

Offline Chen Zhen

  • The Underdog
  • Operations Manager
  • *
  • Posts: 1351
  • Gender: Male
  • Kinesis
    • WebDev
  • SMF Version: 2.1
  • EhPortal Version: 1.22
Re: Enhanced 'Latest Members" block with avatar
« Reply #23 on: April 18, 2016, 04:31:03 PM »
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;
$width = 'width: 45px;';
$height = 'height: 45px;';

$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))
{
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="' . $width . $height . ';border: 1px solid silver;" />' : '') : (stristr($row['avatar'], 'http://') || stristr($row['avatar'], 'https://') ? '<img src="' . $row['avatar'] . '" alt="" style="' . $width . $height . 'border: 1px solid silver;" />' : '<img src="' . $modSettings['avatar_url'] . '/' . $row['avatar'] . '" alt="" style="' . $width . $height . '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="' . $width . $height . '" />',
'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://' || stristr($row['avatar'], 'https://') ? $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, '" class="sp_center">
<a href="', $scripturl, '?action=profile;u=', $member['id'], '">', $member['avatar']['image'], '</a>
</td>
<td style="padding-right: 8px;vertical-align: bottom;overflow: hidden;" class="sp_recent_member_info">', $member['link'], '</td>
</tr>';

echo '
</table>';
}

Adjust these lines from the above to the dimensions you want for the images:
Code: [Select]
$width = 'width: 45px;';
$height = 'height: 45px;';

.. it should work since it forces every avatar to those dimensions.
« Last Edit: April 20, 2016, 05:59:53 AM by Chen Zhen »

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 #24 on: April 18, 2016, 04:47:40 PM »
Once again thank you for looking at this but unfortunately it is having no effect, the avatars are staying in their original size.

I've taken the size right down to:

Code: [Select]
$tihi = 'width: 25px; height: 25px;';
but still the same with no effect.

I set up a test forum which is completely standard with nothing added, and the problem is the same on that one too.  :(

Offline Chen Zhen

  • The Underdog
  • Operations Manager
  • *
  • Posts: 1351
  • Gender: Male
  • Kinesis
    • WebDev
  • SMF Version: 2.1
  • EhPortal Version: 1.22
Re: Enhanced 'Latest Members" block with avatar
« Reply #25 on: April 18, 2016, 09:05:34 PM »

I made changes to the last post.
Please read it again & follow the instructions from it.
All class calls regarding image size (& corresponding container size) have been removed where the style attributes should take effect.

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 #26 on: April 19, 2016, 02:50:12 AM »
Thank you once again.

The revised code returns the following error:

Parse error: syntax error, unexpected '?' in /......./Sources/PortalBlocks.php on line 256

Offline emanuele

  • Developer
  • *
  • Posts: 293
Re: Enhanced 'Latest Members" block with avatar
« Reply #27 on: April 19, 2016, 04:59:36 AM »
* emanuele wonders why people like not to be able to read code...

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;
$width = 'width: 45px;';
$height = 'height: 45px;';

$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))
{
if (!empty($row['id_member']))
$colorids[$row['id_member']] = $row['id_member'];

if ($row['avatar'] == '')
{
if ($row['id_attach'] > 0)
{
if (empty($row['attachment_type']))
{
$avatar_href = $scripturl . '?action=dlattach;attach=' . $row['id_attach'] . ';type=avatar';
}
else
{
$avatar_href = $modSettings['custom_avatar_url'] . '/' . $row['filename'];
}
}
}
else
{
if (stristr($row['avatar'], 'http://') || stristr($row['avatar'], 'https://'))
{
$avatar_href = $row['avatar'];
}
else
{
$avatar_href = $modSettings['avatar_url'] . '/' . $row['avatar'];
}
}
if (!empty($avatar_href))
{
$avatar = '<img src="' . $avatar_href . '" alt="" style="' . $width . $height . ';border: 1px solid silver;" />';
}
else
{
$avatar = '<img src="' . $modSettings['avatar_url'] . '/no_avatar.gif" alt="" style="' . $width . $height . '" />';
}

$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' => $avatar,
'href' => $avatar_href,
'url' => $avatar_href // To me URL and href should always be the same, never really understood why they are treated differently
),
);
}
$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, '" class="sp_center">
<a href="', $scripturl, '?action=profile;u=', $member['id'], '">', $member['avatar']['image'], '</a>
</td>
<td style="padding-right: 8px;vertical-align: bottom;overflow: hidden;" class="sp_recent_member_info">', $member['link'], '</td>
</tr>';

echo '
</table>';
}

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 #28 on: April 19, 2016, 06:02:16 AM »
* Ian M wonders how people are able to read code...

Well that was a journey!!   100% working.

Thank you very much to everyone for your help. Very much appreciated.

Offline emanuele

  • Developer
  • *
  • Posts: 293
Re: Enhanced 'Latest Members" block with avatar
« Reply #29 on: April 19, 2016, 07:38:18 AM »
* Ian M wonders how people are able to read code...
The same way (almost) anyone is able to read a language! :P
Actually, it's even easier because there is no need to conjugate verbs or thing about politeness forms, or the gender, etc.  8)

Offline Chen Zhen

  • The Underdog
  • Operations Manager
  • *
  • Posts: 1351
  • Gender: Male
  • Kinesis
    • WebDev
  • SMF Version: 2.1
  • EhPortal Version: 1.22
Re: Enhanced 'Latest Members" block with avatar
« Reply #30 on: April 19, 2016, 10:45:32 PM »
Oops.. I made a typo with that code which is fixed now.
However if Emanuele's code works as requested then all is well.

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 #31 on: June 18, 2016, 06:28:21 PM »
Didn't realize I forgot a comma. Good catch!