SimplePortal
Customization => Blocks and Modifications => Block Requests => Topic started by: rexall 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 :)
-
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
-
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
-
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.
-
Open /Themes/default/css/portal.css
Find:
td.sp_top_poster, td.sp_staff, td.sp_blog, td.sp_articles
{
width: 45px;
}
Replace with:
td.sp_top_poster, td.sp_staff, td.sp_blog, td.sp_articles, td.sp_recent_member
{
width: 45px;
}
Find:
td.sp_staff_info
{
padding: 7px 0;
vertical-align: bottom;
}
Replace with:
td.sp_staff_info, td.sp_recent_member_info
{
padding: 7px 0;
vertical-align: bottom;
}
Open /Sources/PortalBlocks.php
Find:
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:
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>';
}
-
Hey, Sayaka! Thanks a million! I owe you one.
-
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
-
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.
-
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
-
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!!
-
Pretty sure you messed up somewhere, post the URL please, so I (or a fellow teammate) can check it.
-
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
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
-
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 :/
-
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?
-
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.
-
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:
SELECT m.id_member, m.real_name, m.date_registered, m.is_activated,
a.id_attach, a.attachment_type, a.filename
-
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.
-
Fixed code in Sayaka's post.
-
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 !!
-
Place the attached file into:
../avatars
Replace the entire sp_latestMember() function with the following:
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>';
}
-
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.
-
Example shown below is using 30px dimensions
change this line to the preferred dimensions:
$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)
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>';
-
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
$tihi = 'width: 45px; height: 45px;';
<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!!
-
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:
$width = 'width: 45px;';
$height = 'height: 45px;';
.. it should work since it forces every avatar to those dimensions.
-
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:
$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. :(
-
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.
-
Thank you once again.
The revised code returns the following error:
Parse error: syntax error, unexpected '?' in /......./Sources/PortalBlocks.php on line 256
-
/me wonders why people like not to be able to read code...
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>';
}
-
* 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.
-
* 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)
-
Oops.. I made a typo with that code which is fixed now.
However if Emanuele's code works as requested then all is well.
-
Didn't realize I forgot a comma. Good catch!