Advertisement:

Author Topic: Hiding Avatar on first post only ??  (Read 1697 times)

Offline Mick.

  • Customizer
  • SMF Hero
  • *
  • Posts: 5,421
  • Gender: Male
    • idesignSMF on Facebook
    • @idesign360 on Twitter
    • idesignSMF.com
Hiding Avatar on first post only ??
« 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>';
}

Offline Sir Osis of Liver

  • SMF Super Hero
  • *******
  • Posts: 10,811
  • We were all equal in the end.
Re: Hiding Avatar on first post only ??
« Reply #1 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>';

“The best laid schemes o' mice an' men / Gang aft a-gley.” - Robert Burns

Offline Mick.

  • Customizer
  • SMF Hero
  • *
  • Posts: 5,421
  • Gender: Male
    • idesignSMF on Facebook
    • @idesign360 on Twitter
    • idesignSMF.com
Re: Hiding Avatar on first post only ??
« Reply #2 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

Offline Sir Osis of Liver

  • SMF Super Hero
  • *******
  • Posts: 10,811
  • We were all equal in the end.
Re: Hiding Avatar on first post only ??
« Reply #3 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
“The best laid schemes o' mice an' men / Gang aft a-gley.” - Robert Burns

Offline Mick.

  • Customizer
  • SMF Hero
  • *
  • Posts: 5,421
  • Gender: Male
    • idesignSMF on Facebook
    • @idesign360 on Twitter
    • idesignSMF.com
Re: Hiding Avatar on first post only ??
« Reply #4 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.

Offline Sir Osis of Liver

  • SMF Super Hero
  • *******
  • Posts: 10,811
  • We were all equal in the end.
Re: Hiding Avatar on first post only ??
« Reply #5 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?
“The best laid schemes o' mice an' men / Gang aft a-gley.” - Robert Burns

Offline Mick.

  • Customizer
  • SMF Hero
  • *
  • Posts: 5,421
  • Gender: Male
    • idesignSMF on Facebook
    • @idesign360 on Twitter
    • idesignSMF.com
Re: Hiding Avatar on first post only ??
« Reply #6 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

Offline Mick.

  • Customizer
  • SMF Hero
  • *
  • Posts: 5,421
  • Gender: Male
    • idesignSMF on Facebook
    • @idesign360 on Twitter
    • idesignSMF.com
Re: Hiding Avatar on first post only ??
« Reply #7 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.

Offline shadav

  • Support Specialist
  • Sophist Member
  • *
  • Posts: 1,053
  • Gender: Female
    • shadav on Facebook
    • leashadav on GitHub
    • Ask The Muslims: A Place To Ask Honest Questions and Receive Respectful Answers
Re: Hiding Avatar on first post only ??
« Reply #8 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

Online shawnb61

  • Developer
  • SMF Hero
  • *
  • Posts: 2,967
    • sbulen on GitHub
Re: Hiding Avatar on first post only ??
« Reply #9 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>';
Address the process rather than the outcome.  Then, the outcome becomes more likely.   - Fripp

Offline Mick.

  • Customizer
  • SMF Hero
  • *
  • Posts: 5,421
  • Gender: Male
    • idesignSMF on Facebook
    • @idesign360 on Twitter
    • idesignSMF.com
Re: Hiding Avatar on first post only ??
« Reply #10 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>';
            }
« Last Edit: December 22, 2020, 07:11:31 PM by Mick. »

Offline Steve

  • Freak
  • Support Specialist
  • SMF Hero
  • *
  • Posts: 4,716
  • Gender: Male
  • I have not yet begun to procrastinate.
Re: Hiding Avatar on first post only ??
« Reply #11 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.
Please do not PM me for support.

I just ordered a life alert bracelet so
if I get a life, I'll be notified immediately.

Offline Mick.

  • Customizer
  • SMF Hero
  • *
  • Posts: 5,421
  • Gender: Male
    • idesignSMF on Facebook
    • @idesign360 on Twitter
    • idesignSMF.com
Re: Hiding Avatar on first post only ??
« Reply #12 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>';

Offline Steve

  • Freak
  • Support Specialist
  • SMF Hero
  • *
  • Posts: 4,716
  • Gender: Male
  • I have not yet begun to procrastinate.
Re: Hiding Avatar on first post only ??
« Reply #13 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)?
Please do not PM me for support.

I just ordered a life alert bracelet so
if I get a life, I'll be notified immediately.

Offline Mick.

  • Customizer
  • SMF Hero
  • *
  • Posts: 5,421
  • Gender: Male
    • idesignSMF on Facebook
    • @idesign360 on Twitter
    • idesignSMF.com
Re: Hiding Avatar on first post only ??
« Reply #14 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.