SimplePortal

Customization => Custom Coding => Topic started by: dsantana on August 27, 2010, 04:00:59 PM

Title: "Online Today" block
Post by: dsantana on August 27, 2010, 04:00:59 PM
Hi all you genius people!!!
Is there a way to make a block that shows who has been online today or who has been online in the last 24 hours?

Thanks in advance
Title: Re: "Online Today" block
Post by: excaliburj on August 27, 2010, 04:29:53 PM
Do you have the SMF Mod for Users Online Today installed?
http://custom.simplemachines.org/mods/index.php?mod=217

You need that in place to keep track of the users. Once you do have that, it's a matter of echoing out the info:

Code: [Select]
global $context;
echo implode(', ', $context['list_users_online_today']);

The period used is set in the Control Panel entry for the mod.
Title: Re: "Online Today" block
Post by: dsantana on August 27, 2010, 04:56:21 PM
I can tell you at the bottom of the forum page I get that info already...
http://vintagejetboats.com/forum/index.php?action=forum
Now I want to add that to the bottom of my portal page.
Would I make a php box and add that code you show to make a box?
Title: Re: "Online Today" block
Post by: excaliburj on August 27, 2010, 05:25:04 PM
Yes. If it shows already on your Board Index, the mod is in place and active.

The code I gave is pretty much what outputs it there.
Title: Re: "Online Today" block
Post by: excaliburj on August 27, 2010, 08:07:31 PM
Ah. That won't be adequate. That $context entry will ONLY be filled when on the Board Index (much of what's in that array is highly dependent on 'context' - where you are/what you're doing in the forum).

So, it should be:
Code: [Select]
global $context, $sourcedir;
// Get the user online today list.
if (empty($context['list_users_online_today'])) {
require_once($sourcedir . '/Subs-MembersOnlineToday.php');
$membersOnlineTodayOptions = array(
'sort' => 'login_time',
'reverse_sort' => true,
'period' => 'current_day',
'canview' => 'registered',
);
$context += getMembersOnlineTodayStats($membersOnlineTodayOptions);
}
echo implode(', ', $context['list_users_online_today']);

And you can set the parameters (the $membersOnlineTodayOptions values) according to what you want. From the mod's Readme:

Quote
The following options are possible:

Option: sort
Possible Values: 'login_time', 'member_name'
Description: Sort the user list by either login time or their username

Option: reverse_sort
Possible Values: true, false
Description: Sort the user list in ordinary or reverse order

Option: period
Possible Values: 'current_day', 'last_24_hours', 'last_7_days'
Description: The period the user list covers

Option: canview
Possible Values: 'admin', 'registered', 'everyone'
Description: Determines who can view the user list
SimplePortal 2.3.8 © 2008-2024, SimplePortal