SimplePortal

Customization => Blocks and Modifications => Block Requests => Topic started by: Pinsho on April 30, 2013, 10:51:55 AM

Title: Default avatar in Top Posters block
Post 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

Code: [Select]
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
Title: Re: Default avatar in Top Posters block
Post by: Chen Zhen on April 30, 2013, 04:10:08 PM

In that file find:
Code: [Select]
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..)
Code: [Select]
function sp_topPoster($parameters, $id, $return_parameters = false)
{
global $smcFunc, $context, $scripturl, $modSettings, $txt, $color_profile, $settings;

find:
Code: [Select]
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:
Code: [Select]
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
Title: Re: Default avatar in Top Posters block
Post by: Pinsho on May 01, 2013, 06:40:22 AM
It works nice!!!  :applause:
Many thanks!!!  ;D
Title: Re: Default avatar in Top Posters block
Post by: Chen Zhen on May 01, 2013, 03:59:52 PM
It works nice!!!  :applause:
Many thanks!!!  ;D

I am glad to hear that and you are most welcome.
Title: Re: Default avatar in Top Posters block
Post by: Divecall on June 18, 2013, 08:48:06 PM
Doesn`t work for me...

(SMF 2.0.4, SP 2.3.5 - Default theme, Curve)

What can be the error?
Title: Re: Default avatar in Top Posters block
Post by: Sapinho® on June 19, 2013, 03:31:00 AM
can put your url forum?
Title: Re: Default avatar in Top Posters block
Post by: Divecall on June 19, 2013, 08:48:01 PM
Sorry...working now.

I need to edit this part of the Portalblocks.php twice...

Starting with:
Code: [Select]
<td class="sp_top_poster sp_center">
It exist double, and i was editing booth - now it is workin...
SimplePortal 2.3.8 © 2008-2024, SimplePortal