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:
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:
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'] == 1 OR $vbulletin->options['displayloggedin'] == 2 OR ($vbulletin->options['displayloggedin'] > 2 AND $vbulletin->userinfo['userid'])) AND !$show['search_engine']) {
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.
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.
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).
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(