Simple Machines Community Forum

SMF Support => SMF 2.0.x Support => Topic started by: spiros on May 21, 2020, 11:07:45 AM

Title: Hide online status in display.template (online/offline icon)
Post by: spiros on May 21, 2020, 11:07:45 AM
I am using this (as described here: https://www.simplemachines.org/community/index.php?topic=573194.msg4056070#msg4056070)

// Show online and offline buttons?
if (!empty($modSettings['onlineEnable']) && !$message['member']['is_guest'])
echo '
', $context['can_send_pm'] ? '<a href="' . $message['member']['online']['href'] . '" title="' . $message['member']['online']['label'] . '">' : '', '<span class="', $message['member']['online']['is_online'] ? 'on' : 'off' ,'"></span>', $context['can_send_pm'] ? '</a>' : '';


However, it appears that the default SMF behaviour is for the online icon to appear green for a user who is online, even if one is viewing the post as a guest. How can this be changed so that a guest always sees a gray image (off).
Title: Re: Hide online status in display.template (online/offline icon)
Post by: Arantor on May 21, 2020, 01:46:43 PM
Surely having the icon be visible and green indicates to guests that people are actually online and that the forum has activity with actual people (encourages further signups)?
Title: Re: Hide online status in display.template (online/offline icon)
Post by: Deaks on May 21, 2020, 01:47:06 PM
hi spiros, best advice would be ask Antes in the topic, its been 6 days so I would message him.
Title: Re: Hide online status in display.template (online/offline icon)
Post by: Antes on May 21, 2020, 04:17:12 PM
I agree with Arantor on the subject but for some other reason if you want to make this happen;

// Show online and offline buttons?
if (!empty($modSettings['onlineEnable']) && !$message['member']['is_guest'])
echo '
', $context['can_send_pm'] ? '<a href="' . $message['member']['online']['href'] . '" title="' . $message['member']['online']['label'] . '">' : '', '<span class="', ($message['member']['online']['is_online'] && !$user_info['is_guest']) ? 'on' : 'off' ,'"></span>', $context['can_send_pm'] ? '</a>' : '';
Title: Re: Hide online status in display.template (online/offline icon)
Post by: spiros on May 22, 2020, 04:37:32 AM
Thanks again Antes! Most valuable help. Just tried, but still shows green to a guest.
Title: Re: Hide online status in display.template (online/offline icon)
Post by: Arantor on May 22, 2020, 06:40:05 AM
Is $user_info in the list of global variables for that function?
Title: Re: Hide online status in display.template (online/offline icon)
Post by: spiros on June 03, 2020, 12:30:18 PM
Apparently not. Even after reverting to previous version, I get:

8: Undefined variable: user_info
File: /Display.template.php
Line: 312


Previous version:

// Show online and offline buttons?
if (!empty($modSettings['onlineEnable']) && !$message['member']['is_guest'])
echo '
', $context['can_send_pm'] ? '<a href="' . $message['member']['online']['href'] . '" title="' . $message['member']['online']['label'] . '">' : '', '<span class="', ($message['member']['online']['is_online'] && !$user_info['is_guest']) ? 'on' : 'off' ,'"></span>', $context['can_send_pm'] ? '</a>' : '';
Title: Re: Hide online status in display.template (online/offline icon)
Post by: Kindred on June 03, 2020, 06:18:59 PM
so, put it into the globals list
Title: Re: Hide online status in display.template (online/offline icon)
Post by: spiros on June 04, 2020, 02:15:00 AM
Thanks, where/how do I do that?
Title: Re: Hide online status in display.template (online/offline icon)
Post by: m4z on June 04, 2020, 11:52:17 AM
From line 312, move upwards to the beginning of the function. The first line inside the function (beginning with "global") defines the global variables available inside that function. Add "$user_info" to it.
Title: Re: Hide online status in display.template (online/offline icon)
Post by: spiros on June 04, 2020, 12:13:21 PM
Excellent, thank you!