Simple Machines Community Forum

General Community => Scripting Help => Topic started by: Mick. on December 22, 2020, 05:53:42 PM

Title: Hiding Avatar on first post only ??
Post by: Mick. on December 22, 2020, 05:53:42 PM
So i'm redesigning how my display.template looks in my forum. The idea is to hide the avatar on first post only but still show the avatars from users when there are replies. (Mind you, I'm the only one who creates topics. All my boards are reply only.)

I cant seem to crack the formula so i post here...

I added an (if) so it takes care of the first post thingy... but as expected, it shows the avatar in first post only while the the other avatars are gone.  How can we do this backwards?

Code: [Select]
// Show the user's avatar.
if ($message['id'] == $context['topic_first_message'])
{
if (!empty($modSettings['show_user_images']) && empty($options['show_no_avatars']) && !empty($message['member']['avatar']['image']))

echo '
<li class="avatar">
<a href="', $message['member']['href'], '">', $message['member']['avatar']['image'], '</a>';
echo '
', $message['member']['link'];
echo '
on <a href="', $message['href'], '" rel="nofollow" title="', !empty($message['counter']) ? sprintf($txt['reply_number'], $message['counter'], ' - ') : '', $message['subject'], '" class="smalltext">', $message['time'], '</a>
</li>';
}
Title: Re: Hiding Avatar on first post only ??
Post by: Sir Osis of Liver on December 22, 2020, 06:07:08 PM
Code: [Select]

if (!empty($settings['show_user_images']) && empty($options['show_no_avatars']) && !empty($message['member']['avatar']['image']))

if ($message['id'] != $context['topic_first_message'])

echo '
<li class="avatar">
<a href="', $scripturl, '?action=profile;u=', $message['member']['id'], '">
', $message['member']['avatar']['image'], '
</a>
</li>';

Title: Re: Hiding Avatar on first post only ??
Post by: Mick. on December 22, 2020, 06:11:07 PM
Code: [Select]

if (!empty($settings['show_user_images']) && empty($options['show_no_avatars']) && !empty($message['member']['avatar']['image']))

if ($message['id'] != $context['topic_first_message'])

echo '
<li class="avatar">
<a href="', $scripturl, '?action=profile;u=', $message['member']['id'], '">
', $message['member']['avatar']['image'], '
</a>
</li>';

This hides everything. Ive been there lol
Title: Re: Hiding Avatar on first post only ??
Post by: Sir Osis of Liver on December 22, 2020, 06:17:12 PM
Works on test install, avatar is blocked only on topic starter.

http://www.thekrashsite.com/smf20/index.php?topic=4.msg19#new
Title: Re: Hiding Avatar on first post only ??
Post by: Mick. on December 22, 2020, 06:19:47 PM
Works on test install, avatar is blocked only on topic starter.
What it did was remove the avatar on first post and replies thereafter only leaving the names intact. The idea is to "hide" the avatar on first post while avatars are visible after replies.
Title: Re: Hiding Avatar on first post only ??
Post by: Sir Osis of Liver on December 22, 2020, 06:27:56 PM
http://www.thekrashsite.com/smf20/index.php?topic=4.msg19#new

That theme is using default display template.  Which are you using?
Title: Re: Hiding Avatar on first post only ??
Post by: Mick. on December 22, 2020, 06:42:31 PM
http://www.thekrashsite.com/smf20/index.php?topic=4.msg19#new

That theme is using default display template.  Which are you using?
Same..

You still have user name on there on first post. I'm thinking nothing to show on first post while replies stay the same. Im using 2.1 btw but really no diff from 2.0
Title: Re: Hiding Avatar on first post only ??
Post by: Mick. on December 22, 2020, 06:45:07 PM
I tried many variations but cant crack it. I even tried to cheat it by adding <li class="avatar" style="display:none;"> on first post only but it too removes all avatars.
Title: Re: Hiding Avatar on first post only ??
Post by: shadav on December 22, 2020, 06:46:49 PM
I mean not that I know what I'm taking about but wouldn't you need an else if statement in there

so if first topic display this
else if display that
Title: Re: Hiding Avatar on first post only ??
Post by: shawnb61 on December 22, 2020, 06:47:35 PM
Two fields in $message that may be of help are $message['counter'] and $message['is_message_author'].

Try this:
Code: [Select]
// Show the user's avatar.
if (!empty($modSettings['show_user_images']) && empty($options['show_no_avatars']) && !empty($message['member']['avatar']['image']) && !empty($message['counter']))
echo '
<li class="avatar">
<a href="', $message['member']['href'], '">', $message['member']['avatar']['image'], '</a>
</li>';
Title: Re: Hiding Avatar on first post only ??
Post by: Mick. on December 22, 2020, 06:59:44 PM
Thank you Sir Osis...

Shawn, That did the trick but it showed my name on first post.  I added brackets and now all's good. Thank you.

See in action... https://www.idesignsmf.com/index.php?topic=580.0

My topic at first post, it does not show my avatar. Sweet. Replies show avatars, even sweeter.


Code: [Select]
// Show the user's avatar.
if (!empty($modSettings['show_user_images']) && empty($options['show_no_avatars']) && !empty($message['member']['avatar']['image']) && !empty($message['counter']))
            {
echo '
<li class="avatar">
<a href="', $message['member']['href'], '">', $message['member']['avatar']['image'], '</a>';
echo '
', $message['member']['link'];
echo '
on <a href="', $message['href'], '" rel="nofollow" title="', !empty($message['counter']) ? sprintf($txt['reply_number'], $message['counter'], ' - ') : '', $message['subject'], '" class="smalltext">', $message['time'], '</a>
</li>';
            }
Title: Re: Hiding Avatar on first post only ??
Post by: Steve on December 22, 2020, 07:11:07 PM
So if I want the first post to not show the avatar but show the name, I should use Shawn's code? And if I want neither I should use Micks? And is this user specific? I want it to be only me that this applies to.

Sorry, I'm a little behind since I haven't been here for quite awhile.
Title: Re: Hiding Avatar on first post only ??
Post by: Mick. on December 22, 2020, 07:17:49 PM
So if I want the first post to not show the avatar but show the name, I should use Shawn's code? And if I want neither I should use Micks? And is this user specific? I want it to be only me that this applies to.

Sorry, I'm a little behind since I haven't been here for quite awhile.


This will hide Avatar and name on first post while avatars and names do show in replies. (what i wanted).  Not user specific at all.
Code: [Select]
// Show the user's avatar.
if (!empty($modSettings['show_user_images']) && empty($options['show_no_avatars']) && !empty($message['member']['avatar']['image']) && !empty($message['counter']))
            {
echo '
<li class="avatar">
<a href="', $message['member']['href'], '">', $message['member']['avatar']['image'], '</a>';
echo '
', $message['member']['link'];
echo '
on <a href="', $message['href'], '" rel="nofollow" title="', !empty($message['counter']) ? sprintf($txt['reply_number'], $message['counter'], ' - ') : '', $message['subject'], '" class="smalltext">', $message['time'], '</a>
</li>';
            }


Shawn's code hides avatar on first post but shows name...
Code: [Select]
// Show the user's avatar.
if (!empty($modSettings['show_user_images']) && empty($options['show_no_avatars']) && !empty($message['member']['avatar']['image']) && !empty($message['counter']))
echo '
<li class="avatar">
<a href="', $message['member']['href'], '">', $message['member']['avatar']['image'], '</a>
</li>';
Title: Re: Hiding Avatar on first post only ??
Post by: Steve on December 22, 2020, 07:20:03 PM
Thanks Mick. How hard would it be to make it specific to just me that this applies to (in any board, not just reply only ones)?
Title: Re: Hiding Avatar on first post only ??
Post by: Mick. on December 22, 2020, 07:25:46 PM
Thanks Mick. How hard would it be to make it specific to just me that this applies to (in any board, not just reply only ones)?
At the moment it works with who ever makes the first post anywhere. I imagine that adding a membergroup statement should do the trick. Maybe even if_admin but i have not tried it. Imma play some more and see whats up.