View Full Version : Global variable problem
memobug
10-20-2004, 05:37 AM
I have a conditional in my NavBar template to display Chat status as the link anchor. So it says "Start a Chat" if there is no chat going on and "Join a Chat" if one is already in progress. That text is loaded into a variable $chatwho in the php_include_top template with an @require statement.
The navbar link works perfectly on all pages except my vBadvanced CMPS portal page, where $chatwho is always empty.
How can I make $chatwho carry over into the vBadvanced pages? I tried making $chatwho global in vba_cmps_include_bottom as indicated here:
http://www.vbadvanced.com/forum/showthread.php?t=2912
But no joy
Thanks,
Matt
Brian
10-20-2004, 10:30 AM
Can you post the code that you have in your php_include_top template?
memobug
10-20-2004, 03:09 PM
Sorry, I meant php_include_start not php_include_top. Always get those confused.
Anyway, here it is:
// Example of how to include a separate file:
// ob_start();
// require("yourheader.html");
// $header = ob_get_contents();
// ob_end_clean();
ob_start();
@require("http://url-to-forum/chat/info.php");
$chatwho = ob_get_contents();
ob_end_clean();
Brian
10-20-2004, 03:43 PM
Does it work on your forum pages? You should have a path in the require() function there, not an URL.
memobug
10-21-2004, 02:56 AM
Hi Brian,
Does it work on your forum pages?[quote]
Yes, I had indicated much up top, probably it was not clear:
"The navbar link works perfectly on all pages except my vBadvanced CMPS portal page, where $chatwho is always empty."
[QUOTE=Brian] You should have a path in the require() function there, not an URL.
Well if I put a path in there, it still works only on my vB pages but the vBacmpsindex.php won't load at all.
If I use a URL, it works on all the vB pages (and my photopost pages using the vB header, but not vBA.
I tried paths and URLs with various permutations
(@)include(_once) and got pretty much identical results
Either vbA hung (using paths) or $chatwho= null on vBA pages, while working correctly on all the others.
It's a mystery to me.
Regards,
Matt
Brian
10-21-2004, 10:12 AM
Strange... If you'd like to submit a support ticket I'll be glad to have a look and see if I can figure out what's causing it.
memobug
10-24-2004, 04:49 AM
Thanks Brian, I had the ticket form all filled in, but then I figured it out:
I had my variable $chatwho global-ized in the wrong section (function print_adv_no_permission()). I actually needed to globalize it in the navbar section here:
function construct_adv_navbar($navbits = '', $index = 'false')
{
global $chatwho, $vboptions[...
Now it works fine.
vBulletin® v3.8.4, Copyright ©2000-2012, Jelsoft Enterprises Ltd.