Invision Community 4: SEO, prepare for v5 and dormant account notifications Matt November 11, 2024Nov 11
Posted March 31, 201510 yr Community Expert 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.
March 31, 201510 yr 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>
March 31, 201510 yr Author Community Expert 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! :-)
March 31, 201510 yr 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.
July 13, 20159 yr If no one has reported this to our Bug Tracker, can one of you please do so?This sounds like a bug.Thank you.
July 13, 20159 yr This sounds like a bug.No, I don't think so. It was deliberately removed from the "vertical" view.
Archived
This topic is now archived and is closed to further replies.