- Code: Select all
function page_header($page_title = '', $display_online_list = true, $item_id = 0, $item = 'forum')
{
[SNIP...code removed]
// Get users online list ... if required
$l_online_users = $online_userlist = $l_online_record = $l_online_time = '';
if ($config['load_online'] && $config['load_online_time'] && $display_online_list)
{
/**
* Load online data:
* For obtaining another session column use $item and $item_id in the function-parameter, whereby the column is session_{$item}_id.
*/
$item_id = max($item_id, 0);
$online_users = obtain_users_online($item_id, $item);
$user_online_strings = obtain_users_online_string($online_users, $item_id, $item);
$l_online_users = $user_online_strings['l_online_users'];
$online_userlist = $user_online_strings['online_userlist'];
$total_online_users = $online_users['total_online'];
if ($total_online_users > $config['record_online_users'])
{
set_config('record_online_users', $total_online_users, true);
set_config('record_online_date', time(), true);
}
$l_online_record = sprintf($user->lang['RECORD_ONLINE_USERS'], $config['record_online_users'], $user->format_date($config['record_online_date'], false, true));
$l_online_time = ($config['load_online_time'] == 1) ? 'VIEW_ONLINE_TIME' : 'VIEW_ONLINE_TIMES';
$l_online_time = sprintf($user->lang[$l_online_time], $config['load_online_time']);
}
It is, specifically, these two function calls that generate the information
- Code: Select all
$online_users = obtain_users_online($item_id, $item);
$user_online_strings = obtain_users_online_string($online_users, $item_id, $item);
Generally it is quite easy to display this information by simply including this template var within the html page of your style that you want the information to display on
- Code: Select all
{LOGGED_IN_USER_LIST}
It couldn't be much simpler. But wait, you say you have included that and yet you still can not see the list after refreshing your style in the ACP. Well there are a few reasons that it won't display. Let's take a look at the if statement
- Code: Select all
if ($config['load_online'] && $config['load_online_time'] && $display_online_list)
$display_online_list is already set to true by the page_header function itself
- Code: Select all
function page_header($page_title = '', $display_online_list = true
so if within the php file that is using the html file you want it displayed on has either $config['load_online'] or $config['load_online_time'] set to false then the list will not display. This is the way it is set within viewonline.php which is the only page that specifically sets that variable as false
- Code: Select all
// We do not need to load the who is online box here. ;)
$config['load_online'] = false;
"Okay," you say, "I don't have that line within my php page but the information still isn't displaying."
Let's look at the page_header function again
- Code: Select all
function page_header($page_title = '', $display_online_list = true
As I stated before, the second parameter is always set to true within the function itself, however within many of the php pages you will find code such as this (from memberlist.php)
- Code: Select all
// Output the page
page_header($page_title, false);
the first paramenter is the page title for the page you are on and the second parameter is the display_online_list, so by simply changing the above from
- Code: Select all
// Output the page
page_header($page_title, false);
to
- Code: Select all
// Output the page
page_header($page_title);
and including the template var of, as stated earlier
- Code: Select all
{LOGGED_IN_USER_LIST}
within the memberlist html files (any of the memberlist files) you will then see a list of users who are logged into the forum when viewing a members profile, viewing the memberlist itself, etc.
Couldn't be simpler.
BTW, little caveat, these two functions
- Code: Select all
obtain_users_online
and
- Code: Select all
obtain_users_online_string
generate an additional 3 queries on any page they are used on. Just keep that in the back of your mind if you choose to display this information within your html files.
Happy coding.