vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3 Articles (https://vborg.vbsupport.ru/forumdisplay.php?f=187)
-   -   Adding Currently Active Users to your own vB page (https://vborg.vbsupport.ru/showthread.php?t=187388)

Lynne 08-05-2008 10:00 PM

Adding Currently Active Users to your own vB page
 
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.

Princeton 08-07-2008 03:08 PM

excellent article :up:

this question has been asked numerous times

iogames 08-09-2008 12:48 AM

will do :D

Triky 08-20-2008 03:38 PM

Yup, but haven't you missed the latest step when the user need to call the template into the external page? :p

PHP Code:

<?php 
eval('print_output("' fetch_template('TEST') . '");');
?>

After this, I get this box:

http://img232.imageshack.us/img232/9209/immaginect9.jpg

It is without styles. Is this normal?

Lynne 08-20-2008 04:06 PM

Quote:

Originally Posted by Triky (Post 1603112)
Yup, but haven't you missed the latest step when the user need to call the template into the external page? :p

PHP Code:

<?php 
eval('print_output("' fetch_template('TEST') . '");');
?>

After this, I get this box:

http://img232.imageshack.us/img232/9209/immaginect9.jpg

It is without styles. Is this normal?

No, I didn't miss that. This is what I wrote in my description:
Quote:

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 is just the code you need to add to an already existing, working page.

Triky 08-20-2008 04:50 PM

Ok, excuse me. Then, if I output a template on a external .php page can't I output the style of it? I.e.: css, images, etc.

Lynne 08-20-2008 06:43 PM

Quote:

Originally Posted by Triky (Post 1603166)
Ok, excuse me. Then, if I output a template on a external .php page can't I output the style of it? I.e.: css, images, etc.

Yes, you can have a custom page that looks just like a vb page if you follow the instructions for making a custom page in either of those articles I linked to.

Triky 08-21-2008 07:10 AM

Are you talking to integrated vB pages (like mysite.com/forum/test.php) that includes header, navbar, footer.. or to external pages? That's becouse I want to make an external page (like mysite.com/test.php) where I include my 'who's online' table, with images and styles like it is on the forumhome. Using your method I can't figure it out, as you can see in my precedent image: there are no styles displayed.

Lynne 08-21-2008 01:19 PM

Quote:

Originally Posted by Triky (Post 1603600)
Are you talking to integrated vB pages (like mysite.com/forum/test.php) that includes header, navbar, footer.. or to external pages? That's becouse I want to make an external page (like mysite.com/test.php) where I include my 'who's online' table, with images and styles like it is on the forumhome. Using your method I can't figure it out, as you can see in my precedent image: there are no styles displayed.

You should only do what is in this article *after* you have a working page up and running. If mysite.com/test.php is up and running and has your style, navbar, etc, then you can add the code in this article to add a Currently Active Users block to your page. But, the key is that first you need to have an external page up and working (and you can use either of the two articles I linked to at the begining to set up your external page).

Triky 08-21-2008 04:42 PM

Then, if I want to add that custom block (who's online) to an external .php page that has not my vB style (header, navbar, etc), what do I need to call in my php code in order to let me show also its custom css that it have on my vB forum?
Should I use this code..

PHP Code:

 <?php 

// ####################### SET PHP ENVIRONMENT ########################### 
error_reporting(E_ALL & ~E_NOTICE); 

// #################### DEFINE IMPORTANT CONSTANTS ####################### 
define('NO_REGISTER_GLOBALS'1); 
define('THIS_SCRIPT''test'); // 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( 
     
); 

// pre-cache templates used by all actions 
$globaltemplates = array( 
    
'here I call my custom template name where I've put the who's online html code'
); 

// pre-cache templates used by specific actions 
$actiontemplates = array( 

); 

// ######################### REQUIRE BACK-END ############################ 
require_once('./global.php'); 

// ####################################################################### 
// ######################## START MAIN SCRIPT ############################ 
// ####################################################################### 

eval('print_output("' fetch_template('here I call my custom template name where I've put the who's online html code') . '");'); 

?>

..? I have tried it, but it seems to doesn't work.


All times are GMT. The time now is 01:06 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.01415 seconds
  • Memory Usage 1,788KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_html_printable
  • (9)bbcode_php_printable
  • (4)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete