PDA

View Full Version : phpinclude Not Processed Before forumdisplaybit


DVD Plaza
Mon 28th May '01, 6:04am
Firstly sorry for posting this in here guys - tried to post it into the bugs area but it was saying I didn't have rights?

Now, onto my wierd little problem... :)

Create a variable called $Test in phpinclude, that is set to the string "Hello World!". Use $Test in a whole heap of templates, no worries it causes "Hello World" to be displayed whereever it is used.

Now place $Test into forumdisplay_forumbit_level1_post - you get nothing???

I have a stock standard VB2 installed, absolutely no changes to the code - but totally rewriting each template from scratch.

Thanks guys,

DVD Plaza
Mon 28th May '01, 9:02am
OH NO!!!! - just found the same problem with forumhome_forumbit_level1_nopost and so forth... :eek:

Kier
Mon 28th May '01, 9:42am
This is because those templates are populated by PHP functions, rather than being part of the main body of code.

If you look at the appropriate functions in the code, you will see lines that look like

global $DB_site,$session,(etc.);

You simply need to add your $Test variable to the list of globally-available variables.

There is no way around this.

DVD Plaza
Mon 28th May '01, 9:47am
What if I put global in front of my variables in phpinclude, or you can't do that on the fly?

In any case I ended up having to, unfortunately, dump the contents of the variables I needed directly into the two affected templates. Bummer, but if that's the worst of it then hey what the heck!

JamesUS
Mon 28th May '01, 10:10am
I believe you have to do it in the template function in functions.php

Wayne Luke
Mon 28th May '01, 11:54am
You would have to declare your variables within the functions. Otherwise PHP will declare new variables with the same name just for that function.

This is how the PHP designers decided to handle local and global variable scope. Unfortunately, we have no way around this limitation.

DVD Plaza
Mon 28th May '01, 11:58am
No worries, thanks guys!

Freddie Bingham
Mon 28th May '01, 1:52pm
It is the proper way to handle local vs. global scope imho. Even removing the global keyword and forcing global variables to be sent through the function would be ok by me.

John
Mon 28th May '01, 3:59pm
Just a quick note: you can use $GLOBALS[test] in those templates, as an alternative to adding $test to the PHP code. Using $GLOBALS[test] will still access the $test variable that you are setting up, but will save you having to modify vBulletin's code.

John

DVD Plaza
Mon 28th May '01, 8:30pm
Hey that sounds like the ticket! Thanks John, I'm on a strict mission to not touch the VBulletin code what-so-ever. I don't want to have the nightmare I had with UBB, where I rewrote it so heavily it made upgrading impossible.

Intec
Thu 14th Jun '01, 5:54pm
THX,
but I dont see that footer or header variables are declared in the dovars-function.