SimplePortal
Customization => Blocks and Modifications => Block Requests => Topic started by: Pinsho on April 30, 2013, 10:51:55 AM
-
I would like to set a "default avatar" in Top Posters block for users that do not have it (instead of showing a blank avatar).
I found this code in PortalBlocks.php but I am not a programmer
foreach ($members as $member)
{
echo '
<tr>
<td class="sp_top_poster 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>
', $member['link'], '<br />', $member['output'], '
</td>
</tr>';
}
echo '
</table>';
Could you please help me with this?
Regards
-
In that file find:
function sp_topPoster($parameters, $id, $return_parameters = false)
{
global $smcFunc, $context, $scripturl, $modSettings, $txt, $color_profile;
Replace with (or add the extra global you see..)
function sp_topPoster($parameters, $id, $return_parameters = false)
{
global $smcFunc, $context, $scripturl, $modSettings, $txt, $color_profile, $settings;
find:
foreach ($members as $member)
{
echo '
<tr>
<td class="sp_top_poster 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>
', $member['link'], '<br />', $member['output'], '
</td>
</tr>';
}
replace with:
foreach ($members as $member)
{
if (empty($member['avatar']['href']))
$member['avatar']['href'] = $settings['default_theme_url'] . '/images/sp/default_avatar.gif';
echo '
<tr>
<td class="sp_top_poster 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>
', $member['link'], '<br />
', $member['posts'], ' ', $txt['posts'], '
</td>
</tr>';
}
Use FTP to put your avatar at this file path:
/Themes/default/images/sp/default_avatar.gif
-
It works nice!!! :applause:
Many thanks!!! ;D
-
It works nice!!! :applause:
Many thanks!!! ;D
I am glad to hear that and you are most welcome.
-
Doesn`t work for me...
(SMF 2.0.4, SP 2.3.5 - Default theme, Curve)
What can be the error?
-
can put your url forum?
-
Sorry...working now.
I need to edit this part of the Portalblocks.php twice...
Starting with:
<td class="sp_top_poster sp_center">
It exist double, and i was editing booth - now it is workin...