PDA

View Full Version : Question


no mods
01-20-2008, 12:30 AM
Is there a way to put the "whats going on box" on every page?

Freesteyelz
01-20-2008, 12:50 AM
Hmm...The Users Online will show. I need to step out a bit but I'll check back.

no mods
01-20-2008, 04:13 PM
Anything?

no mods
01-23-2008, 03:16 AM
There has to be a way?

Dismounted
01-23-2008, 03:20 AM
Hook into global_start, and run the queries as done in index.php. Then just put the template code into the right templates.

no mods
01-23-2008, 03:24 AM
Hook into global_start, and run the queries as done in index.php. Then just put the template code into the right templates.

Who did what with who? :eek:

Please explain alittle more as im no coder by any means.

Dismounted
01-23-2008, 05:05 AM
It's going to be hard to explain if you're not a coder, and this isn't really a simple thing. Basically though, you have to replicate how vBulletin generates the information on every page. Which is done as I've written above.

no mods
01-23-2008, 05:55 AM
I kinda get it, mind explaining the steps I take to do it?:)

Freesteyelz
01-23-2008, 06:11 AM
Ooops...This thread completely slipped my mind. Sorry no mods.

In index.php the codes for the What's Going On? box is sectioned but quite lengthly. Just look at $activeusers alone. I'm limited here since I'm not a coder myself. Have you taken a look at Paul M's mod Members Who Have Visited? Good stuff. :D

Hmm...Let me try something...

OK...That didn't work. There has to be an easier way to pull the info into global start...Maybe hire Dismounted? :D

Dismounted
01-23-2008, 07:20 AM
You need to look in index.php and copy the whole block for the What's Going On? box. Then selectively run these processes when a page requires it via a plugin.

Freesteyelz
01-23-2008, 08:18 AM
Thanks, Dismounted...And it's not even my issue. :D

I'm getting closer. :) Either I can pull the names of the active users or I can pull the stats on active users...Only in FORUMHOME I'm able to call both. I think it has to do with the lack of code:


if (fetch_online_status($loggedin))
{
$numbervisible++;
eval('$activeusers .= ", ' . fetch_template('forumhome_loggedinuser') . '";');
}



The problem is that if I hook that into global_start I end up getting a call function error:


Call to undefined function fetch_online_status()



Without that line, I won't be able to pull the names of active users in other pages. I'm missing something here...

Dismounted
01-23-2008, 08:22 AM
You forgot to include the dependants. Specifically in that case, functions_online.php. You also should add a conditional around it so it only runs on the required pages, otherwise, you'd be running it every time the vBulletin backend is called - not good.

Freesteyelz
01-23-2008, 09:08 AM
Ahh...That makes sense. Thanks, Dismounted. :)

So for no mods, he wants to display the What's Going On? box on every page. In this case fetch_online_status, $activeusers and the rest of the codes for What's Going On? will be called. Is there a workaround so that by calling the processes on every page isn't a problem?

Dismounted
01-23-2008, 09:30 AM
It isn't a problem if you limit the calling with THIS_SCRIPT. It is a problem because the vBulletin backend is called for every function. Eg. quick replying. We don't need to do the processing on those calls, so we put a cap on it :).

Freesteyelz
01-23-2008, 10:04 AM
Slowly all of this is making sense to me. No wonder when I called certain processes via plugin it shot through every page when it wasn't intended to. So would THIS_SCRIPT for this instance look something like:


<if condition="in_array(THIS_SCRIPT, array('index', 'forumdisplay', 'showthread', 'search'))">
<div class="smallfont">
<div style="white-space: nowrap">
<!-- currently active users -->
$vbphrase[currently_active_users]: $totalonline (<phrase 1="$numberregistered" 2="$numberguest">$vbphrase[x_members_and_y_guests]</phrase>).&nbsp;
<!-- / currently active users -->
<phrase 1="$recordusers" 2="$recorddate" 3="$recordtime">$vbphrase[most_users_ever_online_was_x_y_at_z]</phrase></div>
<div>$activeusers</div>
</div>
</if>



Or am I out of the ballpark? Again, thanks for your patience. :up:

Dismounted
01-23-2008, 10:31 AM
Yep, spot on with the conditional.

Freesteyelz
01-23-2008, 11:05 AM
Hehe...You're a good teacher. :up:

I think my next step is to get the codes in function_online.php and combine them with $activeusers. Hopefully they'll call approprately across pages. First, I need sleep. :)

For coders, if they are calling a vB process do they typically write their own codes (a variation of vB codes) or do they take actual vB snippets here and there then put them together?

no mods
01-23-2008, 04:41 PM
Thank you Freesteyelz and Dismounted. Im still lost, but if anyone comes to a way to do this let me know. :)

Freesteyelz
01-23-2008, 09:08 PM
I'm still working on it...But if anyone else has an answer do share. :)

Dismounted
01-24-2008, 02:57 AM
I think my next step is to get the codes in function_online.php and combine them with $activeusers. Hopefully they'll call approprately across pages. First, I need sleep. :)
Your next step is to find the whole "What's Going On?" box processing code (in index.php) and copy that into the plugin. Post whatever errors you get when accessing a page so I can help you with those.

Marco van Herwaarden
01-24-2008, 06:45 AM
Slowly all of this is making sense to me. No wonder when I called certain processes via plugin it shot through every page when it wasn't intended to. So would THIS_SCRIPT for this instance look something like:


<if condition="in_array(THIS_SCRIPT, array('index', 'forumdisplay', 'showthread', 'search'))">
<div class="smallfont">
<div style="white-space: nowrap">
<!-- currently active users -->
$vbphrase[currently_active_users]: $totalonline (<phrase 1="$numberregistered" 2="$numberguest">$vbphrase[x_members_and_y_guests]</phrase>).&nbsp;
<!-- / currently active users -->
<phrase 1="$recordusers" 2="$recorddate" 3="$recordtime">$vbphrase[most_users_ever_online_was_x_y_at_z]</phrase></div>
<div>$activeusers</div>
</div>
</if>



Or am I out of the ballpark? Again, thanks for your patience. :up:Maybe i'm out of line with this response, but i did not took the time to read the whole thread again.

You are now limiting showing of the results by using a template conditional. This means that the plugin code is still running on every page. To avoid unneeded processing (retrieving data to check the users online status) i suggest you perform the condition in the plugin before retrieving the data, instead of always retrieving and only sometimes showing.

Dismounted
01-24-2008, 07:26 AM
I presumed that the posted snippet was included in the footer and the conditional was still being used in the plugin. Is this correct, Freesteyelz?

Freesteyelz
01-24-2008, 12:21 PM
Well, the code posted above was in the footer but I may not have set the conditional in the plugiin correctly...Wouldn't it be


if ( defined("THIS_SCRIPT") )


I didn't get a chance to continue last night (4:16am now). However, this is a good opportunity for me to learn how to pull information from PHP scripts and call them into the templates. I'll look into the entire What's Going On? processes in index.php and look into functions_online.php later today or tonight and will post back. Again, I really appreciate the time and help. :)

Dismounted
01-25-2008, 04:14 AM
No, it would be something like:
if (in_array(THIS_SCRIPT, array('showthread', 'forumdisplay')))

Freesteyelz
01-25-2008, 07:56 AM
Ahh, geez. I should have known better to use array rather than define; it's the equivalent to the template conditional. :p By defining which scripts to pull inside the plugin the conditional in the footer template is rather redundant then, right?

I'll have to continue this tomorrow, however. Anyway, thanks for the correction. :)

Dismounted
01-25-2008, 10:29 AM
By defining which scripts to pull inside the plugin the conditional in the footer template is rather redundant then, right?
Not really, because if you have a page that you don't want to have the box, the HTML will still show up, except it would be empty :p.

Marco van Herwaarden
01-25-2008, 10:34 AM
Not really "not really" ;)

Using an in_array() condition in a template is relative expensive (performance wise). Best is to set a single variable in the plugin whenever you are going to show the block. Then use this single variable to show/hide in the template.

Freesteyelz
01-25-2008, 09:29 PM
@Dismounted:
Thanks...I'll use both then. :D


@Marco:
Does that rule apply to all array conditionals or just for plugins? I ask because I use arrays quite a bit across pages to hide/show links and information depending on Usergroups and templates (within templates).

In debug mod there weren't significant or noticable performance changes...But then again I am on a testing platform as the project I'm working on has not been released live yet.

Marco van Herwaarden
01-26-2008, 06:47 AM
In general all template conditions that are not a simple comparison, but use a function (ie. in_array() can_moderate(),....), will have a larger effect on performance then a similar condition in PHP (ie. plugin).

Freesteyelz
01-26-2008, 02:27 PM
Hmm. I think it'll be a good idea for me to learn up on plugins to see if I can set codes more efficiently wherever I'm able to.

Freesteyelz
01-28-2008, 01:07 AM
OK...In the plugin before all code I added:


if (in_array(THIS_SCRIPT, array('forumdisplay')))
{



And after all code I added "}". I also added this code bit back in without errors:


if (fetch_online_status($loggedin))
{
$numbervisible++;
eval('$activeusers .= ", ' . fetch_template('forumhome_loggedinuser') . '";');
}



I just noticed that when viewing the Current Active Users in forumdisplay pages I don't see the invisible users. Even after disabling the hook. The Usergroup permission to see Invisible Users is set to "Yes". Is that vB's normal behavior to only see invisible users in forumhome?

Dismounted
01-28-2008, 05:33 AM
Could you post the exact code you're using?

Freesteyelz
01-29-2008, 12:14 AM
It's quite a large part of vB's index.php (copy and paste) and I don't want to risk breaking the rules. Can you give me a free pass? :D

I hope this helps for now:

I opened with:


if (in_array(THIS_SCRIPT, array('forumdisplay')))
{



I copied and pasted all of the Main Script bits (stopped before Birthday bit):


// ######################### REQUIRE BACK-END ############################
require_once('./global.php');
require_once(DIR . '/includes/functions_bigthree.php');
require_once(DIR . '/includes/functions_forumlist.php');
// ################################################## #####################
// ######################## START MAIN SCRIPT ############################
// ################################################## #####################



And the entire bit of $activeusers and stopped at "// ### GET FORUMS & MODERATOR iCACHES":


// ### LOGGED IN USERS #################################################
$activeusers = '';



And ended all code with:


}