Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Topic started by: MobileCS on December 11, 2016, 01:21:48 AM

Title: ssi_logOnline Output Modification
Post by: MobileCS on December 11, 2016, 01:21:48 AM
I'm modifying the output of ssi_logOnline function. However when doing so, it no longer "logs the user's online presence".

$online_users = ssi_logOnline('array');
$forum_guests = $online_users['guests'];
$forum_users = $online_users['num_users'];
foreach ($online_users['users'] as $user)
{
$forum_username = $user['username'];
$username_link = $user ['href'];
$forum_username_list .= "<a href=\"$username_link\">$forum_username</a>, ";
}
$forum_username_list = rtrim($forum_username_list, ", ");

echo "<p class=\"center\">$forum_guests Guests, $forum_users Users";
echo "<br />$forum_username_list</p>";


When refreshing the webpage, my username no longer moves to the front the of username list + I'll be dropped off the list after 15 minutes unless I visit the forum.

Is this the intended behavior? What can I do to fix this?
Title: Re: ssi_logOnline Output Modification
Post by: Kindred on December 11, 2016, 08:11:06 AM
I am not sure about the front of the user list, but dropped after 15 mins... yes. That is correct and expected behavior
Title: Re: ssi_logOnline Output Modification
Post by: MobileCS on December 11, 2016, 11:50:14 AM
Ok, what exactly is the difference between ssi_whosOnline and ssi_logOnline then?

The wiki shows that ssi_logOnline is "exactly like ssi_whosOnline but it also logs the user's online presence". However, it's not doing that for me.

Unless I am misunderstanding what "logs the user's online presence" means?

Title: Re: ssi_logOnline Output Modification
Post by: Kindred on December 11, 2016, 02:17:12 PM
it logs the user's presence... but unless the user continues to get logged, the 15 minute timeout for online listing starts counting the moment that the log is inititated
Title: Re: ssi_logOnline Output Modification
Post by: MobileCS on December 11, 2016, 03:38:05 PM
What I am seeing is that if I use :

<?php ssi_logOnline(); ?>

Everything works fine, and if I navigate to any page (outside the forum) on my website, my name in the user list gets bumped to the front of the row and it "logs my online presence".

However, when I use :

$online_users = ssi_logOnline('array');

and modify the results myself, this no longer happens - my name no longer bumps to the front of the list. Navigating my website does not "log my online presence".
Title: Re: ssi_logOnline Output Modification
Post by: Kindred on December 11, 2016, 03:53:32 PM
right.... because when you read the output to an array, YOU have to do all of the work for display and db/server sync....  and you'r not doing that second bit.
Title: Re: ssi_logOnline Output Modification
Post by: MobileCS on December 11, 2016, 09:45:38 PM
Yes, but is there a way for me to "enable" the second bit? (log online presence)
Title: Re: ssi_logOnline Output Modification
Post by: Kindred on December 11, 2016, 10:13:54 PM
Look at how the function does it in ssi if you don't read it out as an array