View Full Version : How would I call functions from forumhome in other templates?
dgmayor
01-05-2003, 06:53 PM
I was looking over the template forumhome, and I found the various calls to functions such as $pminfo, $numbermembers, $totalthreads, etc. I was wondering what I had to do to incorporate some of these into the template forumdisplay, or possibly a different one.
I tried the obvious and just called the function from these templates, but they had 0 output, which leads me to believe that they're either contained within the forumhome php file or are called there and I need to include a call somewhere in forumdisplay.
I'm new to PHP but I ran a UBB board for over a year and did a lot of modifications with it and what not. Usually I figure these things out myself, but I'm stumped on this one, since it's a new language to me.
I see a lot of the things I want to do are in 3.0, but well, I'm rather impatient.
Any help would be great!
NTLDR
01-05-2003, 07:20 PM
The variables in the forum home templates are assigned by the code in forum/index.php :)
Take a look in there for the code for them.
Chris M
01-05-2003, 07:32 PM
Globalise the variables;)
Satan
NTLDR
01-05-2003, 07:38 PM
Originally posted by hellsatan
Globalise the variables;)
Thats not going to help, unless every file includes every other one etc etc.
Declaring the global variables allows you to use them outside of there scope, eg using them within functions.
dgmayor
01-05-2003, 08:38 PM
I see the functions, but not quite sure what I need to do. Is there a way to have the forumdisplay templates call those funtions from index.php, or do I need to copy the functions over? Seems a bit redundant to me to do it that way, but I'm unfamiliar with the way things work (been looking at the code for about a day, so I'm still figuring out how things work together).
NTLDR
01-05-2003, 09:09 PM
There not fuctions, the only function in index.php is the one to make the forum bits.
Yes you would need to copy the code from index.php to forumdisplay.php and add the variables like $totalthreads in the templates where you want them.
Boofo
01-05-2003, 09:12 PM
Couldn't you put the code for what you want in the phpinclude template and use it globally from there, too?
NTLDR
01-05-2003, 09:14 PM
You could indeed, however I'd not suggest the phpinclude method unless its used on every page, its gonna add maybe 4 queries per page, which is very wastefull, especially if the info isn't been used on 90% of the site ;). I also wouldn't suggest adding it to forumdisplay, but thats just me.
dgmayor
01-06-2003, 12:26 PM
I can't see it being that big of a deal to add the queries if Vbul 3.0 beta is doing the same thing. Granted I don't know how they have it coded.
Btw, I got it to do what I wanted, so I appreciate the help, even if you don't condone it ;)
konstance
03-14-2003, 05:51 PM
ok, this is a totally stupid question, but where do you define your global variables? I added a new table to my database and i would like to be able to refer to one of the fields in it from 2 different files.... thanks in advance for help.
filburt1
03-14-2003, 06:27 PM
Side note: functions are blocks of code that do something. Variables just store data. There are only variables in vB templates.
To make a variable global, init it outside of a function or use global $whatever (or $_GLOBALS['whatever']) whatever in a function.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.