Hiding Avatar on first post only ??

Started by Mick., December 22, 2020, 05:53:42 PM

Previous topic - Next topic

Mick.

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?

// 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>';
}

Sir Osis of Liver



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>';

Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

Mick.

Quote from: Sir Osis of Liver on December 22, 2020, 06:07:08 PM


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

Sir Osis of Liver

Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

Mick.

Quote from: Sir Osis of Liver on December 22, 2020, 06:17:12 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.

Sir Osis of Liver

Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

Mick.

Quote from: 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?
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

Mick.

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.

shadav

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

shawnb61

Two fields in $message that may be of help are $message['counter'] and $message['is_message_author'].

Try this:
// 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>';

Address the process rather than the outcome.  Then, the outcome becomes more likely.   - Fripp

Mick.

#10
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.



// 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>';
            }

Steve

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.
DO NOT pm me for support!

Mick.

Quote from: 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.


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.

// 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...
// 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>';

Steve

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)?
DO NOT pm me for support!

Mick.

Quote from: 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)?
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.

Advertisement: