View Full Version : Removing the online user page
newmark
03-13-2011, 04:02 PM
Hello, I want to remove the "Online Members" to a different place then Forumhome. I found the below article https://vborg.vbsupport.ru/showthread.php?t=229194 and tried to modify it.
{vb:stylevar htmldoctype}
<html xmlns="http://www.w3.org/1999/xhtml" dir="{vb:stylevar textdirection}" lang="{vb:stylevar languagecode}" id="vbulletin_html">
<head>
<title>{vb:raw vboptions.bbtitle}</title>
{vb:raw headinclude}
</head>
<body>
{vb:raw header}
{vb:raw navbar}
<div id="pagetitle">
<h1>{vb:raw pagetitle}</h1>
</div>
<h2 class="blockhead">Whos Online</h2>
<div class="blockbody">
<div class="blockrow">
<!-- logged-in users -->
<div id="wgo_onlineusers" class="wgo_subblock section">
<h3 class="blocksubhead"><img src="{vb:stylevar imgdir_misc}/users_online.png" alt="{vb:rawphrase currently_active_users}" />{vb:rawphrase currently_active_users}</h3>
<div>
<p>{vb:rawphrase there_are_x_y_online_link, {vb:raw totalonline}, {vb:raw session.sessionurl}} <span class="shade">{vb:rawphrase x_members_and_y_guests, {vb:raw numberregistered}, {vb:raw numberguest}}</span></p>
<p>{vb:rawphrase most_users_ever_online_was_x_y_at_z, {vb:raw recordusers}, {vb:raw recorddate}, {vb:raw recordtime}}</p>
<vb:if condition="$activeusers">
<ol class="commalist" id="wgo_onlineusers_list">
{vb:raw activeusers}
</ol>
</vb:if>
</div>
</div>
<!-- end logged-in users -->
</div>
</div>
{vb:raw footer}
</body>
</html>
New page opens correctly but does not show the online members..I'd be pleased if you help me..
blind-eddie
03-13-2011, 04:08 PM
Whos Online already has a page of its own as well as showing on forum home..Link to it is in your quick links drop down.
newmark
03-13-2011, 04:17 PM
Whos Online already has a page of its own as well as showing on forum home..Link to it is in your quick links drop down.
thanks but what I really want to do is exactly adding the active users to my own vb4 page..
https://vborg.vbsupport.ru/showthread.php?t=187388
the above hack is for vb3..I'm searching the same for vb4..
Lynne
03-13-2011, 04:25 PM
Post the php code you used. The template code looks fine.
newmark
03-13-2011, 04:31 PM
Post the php code you used. The template code looks fine.
Hi Lynee, I've just embedded the below part after <div class="blockrow"> to the original code..it opens the new page but does not show the online users on the new page..
<!-- logged-in users -->
<div id="wgo_onlineusers" class="wgo_subblock section">
<h3 class="blocksubhead"><img src="{vb:stylevar imgdir_misc}/users_online.png" alt="{vb:rawphrase currently_active_users}" />{vb:rawphrase currently_active_users}</h3>
<div>
<p>{vb:rawphrase there_are_x_y_online_link, {vb:raw totalonline}, {vb:raw session.sessionurl}} <span class="shade">{vb:rawphrase x_members_and_y_guests, {vb:raw numberregistered}, {vb:raw numberguest}}</span></p>
<p>{vb:rawphrase most_users_ever_online_was_x_y_at_z, {vb:raw recordusers}, {vb:raw recorddate}, {vb:raw recordtime}}</p>
<vb:if condition="$activeusers">
<ol class="commalist" id="wgo_onlineusers_list">
{vb:raw activeusers}
</ol>
</vb:if>
</div>
</div>
<!-- end logged-in users -->
Original Code:
{vb:stylevar htmldoctype}
<html xmlns="http://www.w3.org/1999/xhtml" dir="{vb:stylevar textdirection}" lang="{vb:stylevar languagecode}" id="vbulletin_html">
<head>
<title>{vb:raw vboptions.bbtitle}</title>
{vb:raw headinclude}
</head>
<body>
{vb:raw header}
{vb:raw navbar}
<div id="pagetitle">
<h1>{vb:raw pagetitle}</h1>
</div>
<h2 class="blockhead">Title</h2>
<div class="blockbody">
<div class="blockrow">
</div>
</div>
{vb:raw footer}
</body>
</html>
Lynne
03-13-2011, 05:13 PM
I see the template code and it looks fine. I want to see what you added in the php page. Actually, more specifically, I want to see if you registered all the variables for use in your template, so I want to see the template render code.
newmark
03-13-2011, 05:34 PM
I see the template code and it looks fine. I want to see what you added in the php page. Actually, more specifically, I want to see if you registered all the variables for use in your template, so I want to see the template render code.
I didn't register anything infact..I just imply the procedure explained in the below link..
https://vborg.vbsupport.ru/showthread.php?t=229194
it says there is no need to create a php file or a plugin..I create a template called "custom_online" and put the above php in it..then I check "/misc.php?do=page&template=online" page it shows the page but it does not show the current active users..
I'd appreciate if you explain how I'd register the variables or what I should do..if you have time and can check, I can also give you admin pass etc..
Lynne
03-13-2011, 06:08 PM
That is the article to create your own page. You need to add code to the page though. You can't just add variables to a page without defining them. See this - Adding Currently Active Users to your own vB page (https://vborg.vbsupport.ru/showthread.php?t=187388)
newmark
03-13-2011, 07:15 PM
Hello Lynne, I followed the steps in your article..I've uploaded the picture of the result page and the modified php code here..it doesn't show the number of people who're online..
http://img372.yukle.tc/images/15091.JPG
this is the php file
<?php
// ####################### SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);
// #################### DEFINE IMPORTANT CONSTANTS #######################
define('THIS_SCRIPT', 'online');
define('CSRF_PROTECTION', true);
// change this depending on your filename
// ################### PRE-CACHE TEMPLATES AND DATA ######################
// get special phrase groups
$phrasegroups = array();
// get special data templates from the datastore
$specialtemplates = array();
$specialtemplates = array(
'maxloggedin',
);
// pre-cache templates used by all actions
$globaltemplates = array('custom_online',
);
$globaltemplates = array(
'online',
'forumhome_loggedinuser',
);
// pre-cache templates used by specific actions
$actiontemplates = array();
// ######################### REQUIRE BACK-END ############################
// if your page is outside of your normal vb forums directory, you should change directories by uncommenting the next line
// chdir ('/path/to/your/forums');
require_once('./global.php');
require_once('./global.php');
require_once(DIR . '/includes/functions_bigthree.php');
// ################################################## #####################
// ######################## START MAIN SCRIPT ############################
// ################################################## #####################
$navbits = construct_navbits(array('' => 'online'));
$navbar = render_navbar_template($navbits);
// ###### YOUR CUSTOM CODE GOES HERE #####
$pagetitle = 'online';
// ### LOGGED IN USERS #################################################
$activeusers = '';
if (($vbulletin->options['displayloggedin'] == 1 OR $vbulletin->options['displayloggedin'] == 2 OR ($vbulletin->options['displayloggedin'] > 2 AND $vbulletin->userinfo['userid'])) AND !$show['search_engine'])
{
$datecut = TIMENOW - $vbulletin->options['cookietimeout'];
$numbervisible = 0;
$numberregistered = 0;
$numberguest = 0;
$hook_query_fields = $hook_query_joins = $hook_query_where = '';
($hook = vBulletinHook::fetch_hook('forumhome_loggedinuser_ query')) ? eval($hook) : false;
$forumusers = $db->query_read_slave("
SELECT
user.username, (user.options & " . $vbulletin->bf_misc_useroptions['invisible'] . ") AS invisible, user.usergroupid, user.lastvisit,
session.userid, session.inforum, session.lastactivity, session.badlocation,
IF(displaygroupid=0, user.usergroupid, displaygroupid) AS displaygroupid, infractiongroupid
$hook_query_fields
FROM " . TABLE_PREFIX . "session AS session
LEFT JOIN " . TABLE_PREFIX . "user AS user ON(user.userid = session.userid)
$hook_query_joins
WHERE session.lastactivity > $datecut
$hook_query_where
" . iif($vbulletin->options['displayloggedin'] == 1 OR $vbulletin->options['displayloggedin'] == 3, "ORDER BY username ASC") . "
");
if ($vbulletin->userinfo['userid'])
{
// fakes the user being online for an initial page view of index.php
$vbulletin->userinfo['joingroupid'] = iif($vbulletin->userinfo['displaygroupid'], $vbulletin->userinfo['displaygroupid'], $vbulletin->userinfo['usergroupid']);
$userinfos = array
(
$vbulletin->userinfo['userid'] => array
(
'userid' =>& $vbulletin->userinfo['userid'],
'username' =>& $vbulletin->userinfo['username'],
'invisible' =>& $vbulletin->userinfo['invisible'],
'inforum' => 0,
'lastactivity' => TIMENOW,
'lastvisit' =>& $vbulletin->userinfo['lastvisit'],
'usergroupid' =>& $vbulletin->userinfo['usergroupid'],
'displaygroupid' =>& $vbulletin->userinfo['displaygroupid'],
'infractiongroupid' =>& $vbulletin->userinfo['infractiongroupid'],
)
);
}
else
{
$userinfos = array();
}
$inforum = array();
while ($loggedin = $db->fetch_array($forumusers))
{
$userid = $loggedin['userid'];
if (!$userid)
{ // Guest
$numberguest++;
if (!isset($inforum["$loggedin[inforum]"]))
{
$inforum["$loggedin[inforum]"] = 0;
}
if (!$loggedin['badlocation'])
{
$inforum["$loggedin[inforum]"]++;
}
}
else if (empty($userinfos["$userid"]) OR ($userinfos["$userid"]['lastactivity'] < $loggedin['lastactivity']))
{
$userinfos["$userid"] = $loggedin;
}
}
if (!$vbulletin->userinfo['userid'] AND $numberguest == 0)
{
$numberguest++;
}
$skipgroups = array(3,4);
foreach ($userinfos AS $userid => $loggedin)
{
if (in_array($loggedin['usergroupid'], $skipgroups))
{
$numberguest++;
}
else
{
$numberregistered++;
if ($userid != $vbulletin->userinfo['userid'] AND !$loggedin['badlocation'])
{
if (!isset($inforum["$loggedin[inforum]"]))
{
$inforum["$loggedin[inforum]"] = 0;
}
$inforum["$loggedin[inforum]"]++;
}
fetch_musername($loggedin);
($hook = vBulletinHook::fetch_hook('forumhome_loggedinuser' )) ? eval($hook) : false;
if (fetch_online_status($loggedin))
{
$numbervisible++;
$show['comma_leader'] = ($activeusers != '');
$templater = vB_Template::create('forumhome_loggedinuser');
$templater->register('loggedin', $loggedin);
$activeusers .= $templater->render();
}
}
}
// memory saving
unset($userinfos, $loggedin);
$db->free_result($forumusers);
$totalonline = $numberregistered + $numberguest;
$numberinvisible = $numberregistered - $numbervisible;
// ### MAX LOGGEDIN USERS ################################
if (intval($vbulletin->maxloggedin['maxonline']) <= $totalonline)
{
$vbulletin->maxloggedin['maxonline'] = $totalonline;
$vbulletin->maxloggedin['maxonlinedate'] = TIMENOW;
build_datastore('maxloggedin', serialize($vbulletin->maxloggedin), 1);
}
$recordusers = vb_number_format($vbulletin->maxloggedin['maxonline']);
$recorddate = vbdate($vbulletin->options['dateformat'], $vbulletin->maxloggedin['maxonlinedate'], true);
$recordtime = vbdate($vbulletin->options['timeformat'], $vbulletin->maxloggedin['maxonlinedate']);
$show['loggedinusers'] = true;
}
else
{
$show['loggedinusers'] = false;
}
// ###### NOW YOUR TEMPLATE IS BEING RENDERED ######
$templater = vB_Template::create('custom_online');
$templater->register_page_templates();
$templater->register('navbar', $navbar);
$templater->register('pagetitle', $pagetitle);
print_output($templater->render());
?>
this is the custom template
{vb:stylevar htmldoctype}
<html xmlns="http://www.w3.org/1999/xhtml" dir="{vb:stylevar textdirection}" lang="{vb:stylevar languagecode}" id="vbulletin_html">
<head>
<title>{vb:raw vboptions.bbtitle} - {vb:raw pagetitle}</title>
{vb:raw headinclude}
{vb:raw headinclude_bottom}
</head>
<body>
{vb:raw header}
{vb:raw navbar}
<div id="pagetitle">
<h1>{vb:raw pagetitle}</h1>
</div>
<h2 class="blockhead">Title</h2>
<div class="blockbody">
<div class="blockrow">
<!-- logged-in users -->
<div id="wgo_onlineusers" class="wgo_subblock section">
<h3 class="blocksubhead"><img src="{vb:stylevar imgdir_misc}/users_online.png" alt="{vb:rawphrase currently_active_users}" />{vb:rawphrase currently_active_users}</h3>
<div>
<p>{vb:rawphrase there_are_x_y_online_link, {vb:raw totalonline}, {vb:raw session.sessionurl}} <span class="shade">{vb:rawphrase x_members_and_y_guests, {vb:raw numberregistered}, {vb:raw numberguest}}</span></p>
<p>{vb:rawphrase most_users_ever_online_was_x_y_at_z, {vb:raw recordusers}, {vb:raw recorddate}, {vb:raw recordtime}}</p>
<vb:if condition="$activeusers">
<ol class="commalist" id="wgo_onlineusers_list">
{vb:raw activeusers}
</ol>
</vb:if>
</div>
</div>
<!-- end logged-in users -->
</div>
</div>
{vb:raw footer}
</body>
</html>
Lynne
03-13-2011, 08:25 PM
You don't need to include global.php twice.
You need to register all the variables you want to use in the template. ie: for the number of users, include this with the other similar lines:
$templater->register('activemembers', $activemembers);
You need to have that line to register every variable you want to include in the template.
newmark
03-19-2011, 05:12 PM
You don't need to include global.php twice.
You need to register all the variables you want to use in the template. ie: for the number of users, include this with the other similar lines:
$templater->register('activemembers', $activemembers);
You need to have that line to register every variable you want to include in the template.
Lynne at last I've achieved :) it works fine now. thanks for your help.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.