Go Back   vb.org Archive > vBulletin Article Depository > Read An Article > vBulletin 3 Articles

Reply
 
Thread Tools
Adding Currently Active Users to your own vB page
Lynne's Avatar
Lynne
Join Date: Sep 2004
Posts: 41,180

 

California/Idaho
Show Printable Version Email this Page Subscription
Lynne Lynne is offline 08-05-2008, 10:00 PM

Adding Currently Active Users to your own vB page


I've seen a few users asking about how to add the list of Currently Active Users to their own vB page. Below I document the lines of code you must add after creating your own page using one of these articles - How to create your own vBulletin-powered page! (uses vB templates) or [How-To] vBulletin API Basics: Creating Custom Pages & Misc. This article only documents what to add to a working page in order to get your Currently Active Users. You should make sure your page is working first before adding this code. I'll refer to your working page as test.php and the template in your working page as 'TEST'.

Instructions

Open your working php page and ADD the maxloggedin template to the specialtemplates array (your maxloggedin users will get reset all the time if you don't add this - I learned that the hard way!):
PHP Code:
// get special data templates from the datastore
$specialtemplates = array(
    
'maxloggedin',
); 
ADD the forumhome_loggedinuser template to the globaltemplates array so it looks like this:
PHP Code:
// pre-cache templates used by all actions
$globaltemplates = array(
    
'TEST',
    
'forumhome_loggedinuser',
); 
Then ADD the functions_bigthree.php to the required files list so it looks like this:
PHP Code:
// ######################### REQUIRE BACK-END ############################
require_once('./global.php');
require_once(
DIR '/includes/functions_bigthree.php'); 
If you are creating this page outside of your normal vb forums directory, you should change directories prior to requiring these files. It would then look like this:
PHP Code:
// ######################### REQUIRE BACK-END ############################
chdir ('/path/to/your/forums');
require_once(
'./global.php');
require_once(
DIR '/includes/functions_bigthree.php'); 
Then open your index.php page and COPY the code between the following START and
END lines. Paste these lines into the main part of your page. (You might want to copy this code from a default index.php if you have modified your index.php page.)

START with:
PHP Code:
// ### LOGGED IN USERS #################################################
$activeusers '';
if ((
$vbulletin->options['displayloggedin'] == OR $vbulletin->options['displayloggedin'] == OR ($vbulletin->options['displayloggedin'] > AND $vbulletin->userinfo['userid'])) AND !$show['search_engine'])

END with:
PHP Code:
    $show['loggedinusers'] = true;
}
else
{
    
$show['loggedinusers'] = false;

Open your template that you made (TEST) and ADD the following code in the table. Make sure it is it's own new table row.
HTML Code:
<!-- logged-in users -->
<tbody>
    <tr>
        <td class="thead" colspan="2">
            <a style="float:$stylevar[right]" href="#top" onclick="return toggle_collapse('forumhome_activeusers')"><img id="collapseimg_forumhome_activeusers" src="$stylevar[imgdir_button]/collapse_thead$vbcollapse[collapseimg_forumhome_activeusers].gif" alt="" border="0" /></a>
            <a href="online.php$session[sessionurl_q]" rel="nofollow">$vbphrase[currently_active_users]</a>: $totalonline (<phrase 1="$numberregistered" 2="$numberguest">$vbphrase[x_members_and_y_guests]</phrase>)
        </td>
    </tr>
</tbody>
<tbody id="collapseobj_forumhome_activeusers" style="$vbcollapse[collapseobj_forumhome_activeusers]">
    <tr>
        <td class="alt2"><a href="online.php$session[sessionurl_q]" rel="nofollow"><img src="$stylevar[imgdir_misc]/whos_online.gif" alt="$vbphrase[view_whos_online]" border="0" /></a></td>
        <td class="alt1" width="100%">
            <div class="smallfont">
                <div style="white-space: nowrap"><phrase 1="$recordusers" 2="$recorddate" 3="$recordtime">$vbphrase[most_users_ever_online_was_x_y_at_z]</phrase></div>
                <div>$activeusers</div>
            </div>
        </td>
    </tr>
</tbody>
<!-- end logged-in users -->
Also, very important if you want your page to validate correctly!, change the other columns to span 2 columns. ie.
HTML Code:
<tr>
    <td class="tcat" colspan="2">Title</td>
</tr>
<tr>
    <td class="alt1" colspan="2">Text</td>
</tr>
That should do it! I tested this on my 3.6.8 board and on my 3.7.0 board.
Reply With Quote
  #42  
Old 02-20-2009, 07:43 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Your path to global.php does not look right. I posted the correct code in the first post:

PHP Code:
chdir ('/path/to/your/forums');
require_once(
'./global.php');
require_once(
DIR '/includes/functions_bigthree.php'); 
Reply With Quote
  #43  
Old 02-24-2009, 01:03 AM
Submerge Submerge is offline
 
Join Date: Jan 2006
Posts: 29
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Lynne;

Thank you for your help thus far. I replaced the code as best as I could understand, but it doesn't seem to recognize users on my site's homepage as being Currently Active Users (even though they are logged in and their account info is being displayed correctly on the homepage).

Here is what I have:
PHP Code:
    //vBulletin Member Recognition
    
$curdir getcwd ();
    
chdir ('/home/ps3t/public_html/forums');
    require_once(
'./global.php');
    require_once(
DIR '/includes/functions_bigthree.php');
    
chdir ($curdir); 
My site's forum is in the /forums/ directory. You can view my site in my signature if you'd like to take a quick look. Am I still incorrectly doing the path? Or does it seem to check out in your mind of how I have it set up? Since the homepage can recognize user's being logged in, I'd think I'd have the path correct, but I'm not an expert at vB programming (but I'm trying!).
Reply With Quote
  #44  
Old 02-24-2009, 03:06 AM
TNCclubman's Avatar
TNCclubman TNCclubman is offline
 
Join Date: Sep 2008
Posts: 690
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

awesome, can you make a couple more tutorials...

1. How to add Todays Events to your custom vB page.

2. How to add Recently Added Albums (from just my user account) to your custom vB page.

Please?

That would be awesome, Im stuck!!
Reply With Quote
  #45  
Old 02-24-2009, 03:37 AM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Submerge View Post
Lynne;

Thank you for your help thus far. I replaced the code as best as I could understand, but it doesn't seem to recognize users on my site's homepage as being Currently Active Users (even though they are logged in and their account info is being displayed correctly on the homepage).

Here is what I have:
PHP Code:
    //vBulletin Member Recognition
    
$curdir getcwd ();
    
chdir ('/home/ps3t/public_html/forums');
    require_once(
'./global.php');
    require_once(
DIR '/includes/functions_bigthree.php');
    
chdir ($curdir); 
My site's forum is in the /forums/ directory. You can view my site in my signature if you'd like to take a quick look. Am I still incorrectly doing the path? Or does it seem to check out in your mind of how I have it set up? Since the homepage can recognize user's being logged in, I'd think I'd have the path correct, but I'm not an expert at vB programming (but I'm trying!).
It's really hard to tell why it isn't working without seeing all the code and your template. Maybe you should post in one of the Community Discussions forums and post the code for the page there.
Quote:
Originally Posted by TNCclubman View Post
awesome, can you make a couple more tutorials...

1. How to add Todays Events to your custom vB page.

2. How to add Recently Added Albums (from just my user account) to your custom vB page.

Please?

That would be awesome, Im stuck!!
I doubt I will be doing that since I don't need either of those things on my forum.
Reply With Quote
  #46  
Old 04-17-2009, 08:38 AM
externalaw.com externalaw.com is offline
 
Join Date: Nov 2008
Posts: 51
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Lynne,

I just want to display current online users at the top of each page, so I guess in the header,
How can I do this?
Reply With Quote
  #47  
Old 04-17-2009, 09:16 AM
Floris Floris is offline
 
Join Date: Jan 2002
Posts: 1,898
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You can use the first post as a guide to see how it is done, and re-apply it to the other sections where you need it. It is not too hard to figure out. Good luck tweaking your site
Reply With Quote
  #48  
Old 02-14-2010, 03:38 PM
khuhner khuhner is offline
 
Join Date: Aug 2009
Posts: 31
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Lynne:

I just found this article and would like to install it. However I'm still new to vb. I have a local site running 4.0.1 and would like to have a widget on the home page of the site (not forums) that I can include Active Users. However this article says you have to create a new page. I have no programming experience in vb so any help getting this into a vb 4.0* widget would be appreciated!

Kurt

--------------- Added [DATE]1266169882[/DATE] at [TIME]1266169882[/TIME] ---------------

Quote:
Originally Posted by khuhner View Post
I just found this article and would like to install it. However I'm still new to vb. I have a local site running 4.0.1 and would like to have a widget on the home page of the site (not forums) that I can include Active Users. However this article says you have to create a new page. I have no programming experience in vb so any help getting this into a vb 4.0* widget would be appreciated!
Well I kept searching and found your article on doin this exact thing!
https://vborg.vbsupport.ru/showthread.php?t=230428

It would be nice to see a lot more "widget" choices like this to allow end users to pick and choose which to include, rather than having to add the code manually. Hopefully vB 4.02+ will support more widgets available by default

Thanks so much for the mod! I marked as installed.

Kurt
Reply With Quote
  #49  
Old 04-04-2012, 02:39 AM
Tyran1 Tyran1 is offline
 
Join Date: Jan 2007
Location: Deutsches Reich
Posts: 297
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Works with 3.8.7

Statistik ??
Reply With Quote
Reply

Thread Tools

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 02:53 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04601 seconds
  • Memory Usage 2,330KB
  • Queries Executed 26 (?)
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
  • (2)bbcode_html
  • (9)bbcode_php
  • (3)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_article
  • (1)navbar
  • (4)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (9)post_thanks_box
  • (9)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (9)post_thanks_postbit_info
  • (8)postbit
  • (9)postbit_onlinestatus
  • (9)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_postinfo_query
  • fetch_postinfo
  • 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