solved Site-wide 'online now' as in forums

iamtimbo
@iamtimbo
10 years ago
301 posts
I'm getting lots of visits, but few engagements. I'd like to insert a box on the home page that shows how many users and guests are online site-wide - just like at the bottom of the forums. I'm hoping that people seeing they are not alone may encourage participation!

Cheers,

Tim
updated by @iamtimbo: 09/19/15 08:05:48AM
douglas
@douglas
10 years ago
2,797 posts
Use the jrUser_whos_online function.

{jrUser_whos_online template="whos_online.tpl"}

whos_online.tpl
{if isset($master)}
    Master Admins
    {foreach from=$master item="m_admin"}
        <a href="{$jamroom_url}">{jrCore_module_function function="jrImage_display" module="jrUser" type="user_image" item_id=$m_admin.session_user_id size="xsmall" crop="auto" class="iloutline" alt=$m_admin.session_user_name title=$m_admin.session_user_name}</a><br><br>
    {/foreach}
{/if}

{if isset($admin)}
    Site Admins<br>
    {foreach from=$admin item="s_admin"}
        <a href="{$jamroom_url}/{$s_admin.profile_url}">{jrCore_module_function function="jrImage_display" module="jrUser" type="user_image" item_id=$s_admin.session_user_id size="xsmall" crop="auto" class="iloutline" alt=$s_admin.session_user_name title=$s_admin.session_user_name}</a><br><br>
    {/foreach}
{/if}

{if isset($user)}
    Members<br>
    {foreach from=$user item="member"}
        <a href="{$jamroom_url}/{$member.profile_url}">{jrCore_module_function function="jrImage_display" module="jrUser" type="user_image" item_id=$member.session_user_id size="xsmall" crop="auto" class="iloutline" alt=$member.session_user_name title=$member.session_user_name}</a><br><br>
    {/foreach}
{/if}

<hr>
    Master Admins: {$master_count}<br>
    Site Admins: {$admin_count}<br>
    Members: {$user_count}<br>
    Visitors: {$visitor_count}<br>
    Total: {$all_count}



--

Douglas Hackney
Jamroom Team - Designer/Developer/Support
FAQ-Docs-Help Videos
iamtimbo
@iamtimbo
10 years ago
301 posts
Douglas - that's brilliant - and so granular, too. Going to have a play with this now...thank you!
iamtimbo
@iamtimbo
10 years ago
301 posts
All looks good, and works a treat, although it has added 20 to the 'visitor' count that the Admin Dashboard is registering, which is odd!

EDIT: Also just seen that this is only visible to logged in users - is there a way that everyone can see it?

EDIT 2: Cleared cache again, and now visible to all...
updated by @iamtimbo: 08/13/15 12:14:38PM
douglas
@douglas
10 years ago
2,797 posts
Glad you got it sorted. :)


--

Douglas Hackney
Jamroom Team - Designer/Developer/Support
FAQ-Docs-Help Videos
iamtimbo
@iamtimbo
10 years ago
301 posts
Yes - although it does always show 20 more visitors than there are - on one occasion it briefly showed 19 more - I'm not sure how that can occur, as $visitor_count isn't modified in your template....
douglas
@douglas
10 years ago
2,797 posts
I'm not sure I understand, how do you know there are 20 more visitors than there are suppose to be?

The dashboard only shows logged in users, it doesn't show how many non logged in visitors are on your site.


--

Douglas Hackney
Jamroom Team - Designer/Developer/Support
FAQ-Docs-Help Videos
iamtimbo
@iamtimbo
10 years ago
301 posts
We're very new - essentially still testing, but don't get loads of traffic yet, from analytics and experience, we've *never* had 20 visitors online at the same time. I don't see that we have a constant undercurrent of 19/20 visitors. It's currently showing the following values:

$master_count as 1
$admin_count as 0
$user_count as 0
$visitor_count as 19

The dashboard shows as per the attachment in Users Online. I'm confused about your dashboard point - in the Users Online tab, I frequently see 'visitor' as the User Name, and have always assumed that was a non-logged in user just browsing the site.

I've got to pop out now, but you can see it at ourtownstory.co.uk on the home page - note that for the purposes of the display, Site Admins is actually the count of the Master Admins - we don't have any site admins yet. You'll see that 'visitors is never lower than 19.
image.jpg
image.jpg  •  26KB