UBB.Dev
Posted By: ScottCargill Users Currently Online - 12/28/2003 7:44 PM
How would I go about adding a Users Currently Online statement to the ubbthreads.tmpl file?

What I'd like to do is put a statement of current # of users online right under their user name. The trick seems to be to get $a,$r,$totalon etc to showup. they don't appear to pass through once you're at the main index screen.
Posted By: Dunk Re: Users Currently Online - 12/28/2003 9:57 PM
I'd also like to know if it is possible to add a hack to 6.4 which allows users to be displayed on individual forums of my choice. I thought I'd tag my question in here.
Posted By: Dalantech Re: Users Currently Online - 12/28/2003 11:22 PM
I was curious, so I looked into the ubbthreads.php and postlist.php files. Both of them use $a and $r variable for the user count. So you could do something like this in your ubbt_registered.tmpl file:

Code
 $r {$ubbt_lang['C_ONLINE2']} $a {$ubbt_lang['C_ONLINE4']}


That's the same script that's used in the ubbthreads.tmpl file. Since the $ubbt_lang variables are in the generic.php language file that script should work for all pages (at least you'll get the words). Keep in mind that the ubbthreads.php file will generate a value for $r and $a that are for the entire forum, but the postlist.php file will generate a $r and $a that is just for the forum being viewed.

You could add your own custom language entries in the generic.php file and create unique text for your hack
Posted By: Dalantech Re: Users Currently Online - 12/28/2003 11:23 PM
[]Dunk said:
I'd also like to know if it is possible to add a hack to 6.4 which allows users to be displayed on individual forums of my choice. I thought I'd tag my question in here. [/]

Right now the number of users online is displayed on all forums. Do you want the ability to disable it?

P.S. In the future start a new thread for your question. Tagging your question on to an existing thread will guarenty that it will get lost...
Posted By: omegatron Re: Users Currently Online - 12/28/2003 11:38 PM
You could use this mod here

https://www.ubbdev.com/forum/showflat.php/Number/96321

Then you have these instructions here would be this

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XX Search in ubbthreads.php :
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

include("$thispath/templates/$tempstyle/ubbthreads.tmpl");

XXXXXXXXXXXXXXXXXXXXXXX
XX Replace it with :
XXXXXXXXXXXXXXXXXXXXXX


include("$thispath/index_whosonline.php");
include("$thispath/templates/$tempstyle/ubbthreads.tmpl");


You could change this part:

include("$thispath/index_whosonline.php");
include("$thispath/templates/$tempstyle/ubbthreads.tmpl");


to somemthing like this


if ( $Board = 'forum1' ) {

include("$thispath/index_whosonline.php");

}

include("$thispath/templates/$tempstyle/ubbthreads.tmpl");


or for multiple forums


if ( ( $Board = 'forum1' ) && ( $Board = 'forum2' ) && ( $Board = 'forum1' ) ) {

include("$thispath/index_whosonline.php");

}

include("$thispath/templates/$tempstyle/ubbthreads.tmpl");


Of course your would replace the forum1 forum2 forum3 with board keywords.
Posted By: ScottCargill Re: Users Currently Online - 12/28/2003 11:42 PM
Exactly, thats where I was on this thing. Pulling in the text and such worked fine, Getting $r or $a or anything else seems to be the trick. I'm thinking that registerednav.tmpl is coming in before those variables are assigned. So in essence they don't exist yet.

Code
  $r {$ubbt_lang['C_ONLINE2']} $a {$ubbt_lang['C_ONLINE4']}


Does exactly as advertised, gives you the text. What I'm after is the total users online to be displayed at the top of the screen, as opposed to being at the bottom. Actually in my case I don't care if it's done in both places.

Thanks for the reply, and effort.
Posted By: Dalantech Re: Users Currently Online - 12/28/2003 11:46 PM
Yup, the ubbt_registerednav.tmpl file would be called before the variables are generated

You could move that piece of script to the top of the ubbthreads.php file -it wouldn't be in the menu, but at least it would be up at the top of the page...
Posted By: Dalantech Re: Users Currently Online - 12/28/2003 11:56 PM
You could add the script in the ubbthreads.php file from lines 237 to 259 (look for Let's see how many user's are viewing each forum ) to your ubbt_registerednav.tmpl file. It might be a little ugly, cause you'd be adding another database query to every page, but it should work. Remember that the templates are constructed as one big echo, so you'll have to come out of echo, execute the php script, and then go back to echoing html. Something like this:

UBBTPRINT;

Execute some php scripting here

echo <<<UBBTPRINT
now we are back to echoing out html


Posted By: ScottCargill Re: Users Currently Online - 12/29/2003 12:04 AM
Uggg... you're right, that'd be a load on the server wouldn't it.
Posted By: omegatron Re: Users Currently Online - 12/29/2003 12:16 AM
Besides the fact that you would need to add more than the online code. The max online date would not display right as some more code is needed. I tried it for you and it displayed but would need more looking at to get the date time to display other than 12/31/69
Posted By: ScottCargill Re: Users Currently Online - 12/29/2003 12:27 AM
Thanks to both you and DalTech.

The only way I can see pulling this off is to code the registered nav to such that it would at ever instance run the numbers itself. which means a moderate hit to system resources every time someone clicks a link as that .tmpl is going to get called every chance it gets.

I'm thinking it may be a better idea to add a table row to the forums list and bring it in there?
Posted By: omegatron Re: Users Currently Online - 12/29/2003 12:40 AM
That works quite well

At the top of ubbthreads.tmpl after the $tbopen add this

<tr>
<td colspan="5" class="darktable">
{$ubbt_lang['C_ONLINE']} $r {$ubbt_lang['C_ONLINE2']} $a {$ubbt_lang['C_ONLINE3']}
<br />
{$ubbt_lang['MAX_ONLINE']} $c_maxonline @ $maxonlinetime
<br />
</td>
</tr>
Posted By: ScottCargill Re: Users Currently Online - 12/29/2003 12:55 AM
That worked pretty good. I had just tried this..

$tbopen
There are currently $r {$ubbt_lang['C_ONLINE2']} $a anonymous users online.
$tbclose

right after the $only_favs and prior to the $tbopen.

Creating a seperate table for the number of users currently online.


Thanks for helping me walk through this. Every little bit helps in the overall understanding of where and how things work.
Posted By: omegatron Re: Users Currently Online - 12/29/2003 12:58 AM
well your missing some html in that statement

try this above the tbopen

$tbopen
<tr>
<td colspan="5" class="darktable">
{$ubbt_lang['C_ONLINE']} $r {$ubbt_lang['C_ONLINE2']} $a {$ubbt_lang['C_ONLINE3']}
<br />
{$ubbt_lang['MAX_ONLINE']} $c_maxonline @ $maxonlinetime
<br />
</td>
</tr>
$tbclose
<br />

You can remove this part if you dont want the maxonline there

<br />
{$ubbt_lang['MAX_ONLINE']} $c_maxonline @ $maxonlinetime
Posted By: ScottCargill Re: Users Currently Online - 12/29/2003 1:12 AM
OH YEah! thats MUCH better, Thanks.
© UBB.Developers