Instructions on how to display a list of members / guests currently viewing the forum
on any webpage via SSI (tested on .shtml pages)
Example (with visitors): Viewing the Forum: Pete, John, Dave and 15 guests
Example (without visitors): Viewing the Forum: No members and no guests
------------------------------
1. Create 2 globals:
(Admin/Templates/Global Vars)
GLOBAL:
sub {
my @found = ();
$DB->table('Online')->delete(GT::SQL::Condition->new(online_time => '<' => (time - $CFG->{online_timeout} * 60)));
my $table = $DB->table('Online','User');
my $sth = $table->select( { 'Online.online_invisible' => 0, 'User.user_invisible' => 0, 'Online.guest_id_fk' => 0 }, ['User.user_username'] );
while (my $userid = $sth->fetchrow_hashref){
push @found, $userid->{user_username};
}
return '' . (@found ? join(', ', @found) : 'No members');
}
GLOBAL:
sub {
return $DB->table('Guest')->count( GT::SQL::Condition->new('guest_last_time', '>', time - 900) );
}
2. Create a template:
(Admin/Templates/User Templates)
To do this I opened .tplinfo and replaced the contents with the following then below where
it displays "Save template as:" rename it to ssi_online.html and click Save.
<head>
<%include include_css.html%>
</head>
<body bgcolor="<%light_green%>">
Viewing the Forums:</a> <%online_now%> and <%online_guest%> guests</font>
</body>
</html>(This is just a basic code. You can change it to whatever font, color, etc. to match your site theme.)
3. Create an Action
(Admin/Setup/Actions)
Add Action - ssi_online
Description - ssi online (or whatever you want to call it)
Enabled - Yes
Page - ssi_online.html
To call it via SSI use the following (change to your path):
on any webpage via SSI (tested on .shtml pages)
Example (with visitors): Viewing the Forum: Pete, John, Dave and 15 guests
Example (without visitors): Viewing the Forum: No members and no guests
------------------------------
1. Create 2 globals:
(Admin/Templates/Global Vars)
Code:
TAG: online_now GLOBAL:
sub {
my @found = ();
$DB->table('Online')->delete(GT::SQL::Condition->new(online_time => '<' => (time - $CFG->{online_timeout} * 60)));
my $table = $DB->table('Online','User');
my $sth = $table->select( { 'Online.online_invisible' => 0, 'User.user_invisible' => 0, 'Online.guest_id_fk' => 0 }, ['User.user_username'] );
while (my $userid = $sth->fetchrow_hashref){
push @found, $userid->{user_username};
}
return '' . (@found ? join(', ', @found) : 'No members');
}
Code:
TAG: online_guest GLOBAL:
sub {
return $DB->table('Guest')->count( GT::SQL::Condition->new('guest_last_time', '>', time - 900) );
}
2. Create a template:
(Admin/Templates/User Templates)
To do this I opened .tplinfo and replaced the contents with the following then below where
it displays "Save template as:" rename it to ssi_online.html and click Save.
Code:
<html> <head>
<%include include_css.html%>
</head>
<body bgcolor="<%light_green%>">
Viewing the Forums:</a> <%online_now%> and <%online_guest%> guests</font>
</body>
</html>
3. Create an Action
(Admin/Setup/Actions)
Add Action - ssi_online
Description - ssi online (or whatever you want to call it)
Enabled - Yes
Page - ssi_online.html
To call it via SSI use the following (change to your path):
Code:
<!--#include virtual="/cgi-bin/forum/gforum.cgi?do=ssi_online"-->