PDA

View Full Version : What Are the Global Variable Scope Exceptions


binaryg
09-14-2009, 04:11 PM
I've been trying to get this code to work for quite a while and it's just not working. I've got a global variable defined that works in headerinclude and navbar but when I try to use it in SHOWTHREAD_SHOWPOST it's empty.

When a thread is loaded, this variable would essentially be used 3 different times throughout the page but it doesn't work when it's called from showthread_showpost.

I've been searching for hours and haven't come up with anything. Is SHOWTHREAD_SHOWPOST one of those templates that isn't in the global scope? If so, how I can I bring it into scope?

Lynne
09-14-2009, 05:30 PM
How are you calling it? $GLOBALS[yourvariable]?

binaryg
09-14-2009, 06:18 PM
In the PHP code ive used global $variable as well as $variable and in the template, when I use $globals[variable] it doesn't work...

At the moment I'm using $variable in 2 locations and it's working fine, in showthread_showpost I'm calling that variable in 3 different locations using both $globals[variable] and $variable but I'm not seeing it show up anywhere... To make sure there wasn't any other program modifying the display of that section I added it right below the body tag and right above the end body tag.

Quick FYI:

$GLOBALS is case sensitive; it must be capitalized.

yeah, I had thought of that and used both :-)

Adrian Schneider
09-14-2009, 06:19 PM
Quick FYI:

$GLOBALS is case sensitive; it must be capitalized.

binaryg
09-14-2009, 06:34 PM
Ughh... All 15 of the references are showing up... but my understanding of the templating system is wrong... showthread_showpost only works for showpost.php... I suppose I just need to find the correct location in another template

Lynne
09-14-2009, 07:01 PM
To find the template you want to modify, do this - vboptions > General Settings > Add Template Name in HTML Comments > set to Yes . Then go back to your page and view the source code and you will see the name of the template called around your part of the code. Sometimes the template is the one mentioned at the very top of the page source.

binaryg
09-14-2009, 07:08 PM
Wow, that's extremely helpful. I had no idea that was there

Thank you

I found where I needed to edit and all is well.