Invision Community 4: SEO, prepare for v5 and dormant account notifications By Matt Monday at 02:04 PM
opentype Posted March 31, 2015 Posted March 31, 2015 The Who is Online widget shows a members + anonymous + guest count when in horizontal mode, but in vertical mode, guests are omitted. I checked the widget template and it seems that the $guest variable is simply not available when the widget is in the sidebar. Anyone knows a simple way to show the guest count in the sidebar or even globally? It helps to show first-time visitors that the site is actually quite busy and therefore possibly worth joining.
Adriano Faria Posted March 31, 2015 Posted March 31, 2015 If you remove the IF/ENDIF, it will show. Find: {{if $orientation == 'horizontal'}} <span class='ipsType_light ipsType_unbold ipsType_medium'>{lang="block_whos_online_info_members" pluralize="$memberCount"}, {lang="block_whos_online_info_anonymous" pluralize="$anonymous"}, {lang="block_whos_online_info_guests" pluralize="$guests"}</span> {{endif}} Change to: <span class='ipsType_light ipsType_unbold ipsType_medium'>{lang="block_whos_online_info_members" pluralize="$memberCount"}, {lang="block_whos_online_info_anonymous" pluralize="$anonymous"}, {lang="block_whos_online_info_guests" pluralize="$guests"}</span>
opentype Posted March 31, 2015 Author Posted March 31, 2015 I tried that before but the guest count was always “0”. But maybe that’s a result of the sidebar caching. Will try again. Thanks! :-)
Adriano Faria Posted March 31, 2015 Posted March 31, 2015 You're right. It is controlled on PHP widget file (applications\core\widgets\whosOnline.php): /* Get guests count */ $memberCount = 0; $guests = 0; $anonymous = 0; if ( $this->orientation === 'horizontal' ) { foreach ( \IPS\Db::i()->select( 'login_type, COUNT(*) AS count', 'core_sessions', array( 'running_time>' . \IPS\DateTime::create()->sub( new \DateInterval( 'PT30M' ) )->getTimeStamp() ), NULL, NULL, 'login_type' ) as $row ) { switch ( $row['login_type'] ) { case \IPS\Session\Front::LOGIN_TYPE_MEMBER: $memberCount += $row['count']; break; case \IPS\Session\Front::LOGIN_TYPE_ANONYMOUS: $anonymous += $row['count']; break; case \IPS\Session\Front::LOGIN_TYPE_GUEST: $guests += $row['count']; break; } } } else { $memberCount = count( $members ); } If you change it to: /* Get guests count */ $memberCount = 0; $guests = 0; $anonymous = 0; /*if ( $this->orientation === 'horizontal' ) {*/ foreach ( \IPS\Db::i()->select( 'login_type, COUNT(*) AS count', 'core_sessions', array( 'running_time>' . \IPS\DateTime::create()->sub( new \DateInterval( 'PT30M' ) )->getTimeStamp() ), NULL, NULL, 'login_type' ) as $row ) { switch ( $row['login_type'] ) { case \IPS\Session\Front::LOGIN_TYPE_MEMBER: $memberCount += $row['count']; break; case \IPS\Session\Front::LOGIN_TYPE_ANONYMOUS: $anonymous += $row['count']; break; case \IPS\Session\Front::LOGIN_TYPE_GUEST: $guests += $row['count']; break; } } /*} else { $memberCount = count( $members ); }*/ guests will appear. But I'm not sure why hide the counter even on a code level. Don't know the reason behind this. Anyway, it was just a quick test. Test on your board and see if it works fine.
Mark H Posted July 13, 2015 Posted July 13, 2015 If no one has reported this to our Bug Tracker, can one of you please do so?This sounds like a bug.Thank you.
Adriano Faria Posted July 13, 2015 Posted July 13, 2015 This sounds like a bug.No, I don't think so. It was deliberately removed from the "vertical" view.
Mark H Posted July 13, 2015 Posted July 13, 2015 The removal may be the bug. Please report this so it can be addressed. Thank you.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.