Jump to content

Showing guest count in sidebar or globally?


opentype

Recommended Posts

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. :cry:

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. 

Link to comment
Share on other sites

If you remove the IF/ENDIF, it will show. Find:

	{{if $orientation == 'horizontal'}}
		&nbsp;&nbsp;<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:

	&nbsp;&nbsp;<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>

Capturar.thumb.PNG.baf3da43f6edb4e830256

Link to comment
Share on other sites

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.

Capturar.thumb.PNG.624770bd6c14e16ee9ad7

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.

Link to comment
Share on other sites

  • 3 months later...

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...