Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 General Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 03-13-2011, 04:02 PM
newmark newmark is offline
 
Join Date: Sep 2010
Posts: 13
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Removing the online user page

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.

PHP 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">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..
Reply With Quote
  #2  
Old 03-13-2011, 04:08 PM
blind-eddie's Avatar
blind-eddie blind-eddie is offline
 
Join Date: Apr 2006
Location: Michigan
Posts: 2,310
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #3  
Old 03-13-2011, 04:17 PM
newmark newmark is offline
 
Join Date: Sep 2010
Posts: 13
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by blind-eddie View Post
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..
Reply With Quote
  #4  
Old 03-13-2011, 04:25 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Post the php code you used. The template code looks fine.
Reply With Quote
  #5  
Old 03-13-2011, 04:31 PM
newmark newmark is offline
 
Join Date: Sep 2010
Posts: 13
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Lynne View Post
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..

PHP Code:
<!-- 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:
PHP 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
Reply With Quote
  #6  
Old 03-13-2011, 05:13 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #7  
Old 03-13-2011, 05:34 PM
newmark newmark is offline
 
Join Date: Sep 2010
Posts: 13
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Lynne View Post
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..
Reply With Quote
  #8  
Old 03-13-2011, 06:08 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply With Quote
  #9  
Old 03-13-2011, 07:15 PM
newmark newmark is offline
 
Join Date: Sep 2010
Posts: 13
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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 Code:
<?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'] == OR $vbulletin->options['displayloggedin'] == OR ($vbulletin->options['displayloggedin'] > 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'] == 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

PHP 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} - {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
Reply With Quote
  #10  
Old 03-13-2011, 08:25 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 01:43 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.05123 seconds
  • Memory Usage 2,407KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (5)bbcode_php
  • (3)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete