![]() |
Getting include statements to work in the forum templates?
I have looked at the following threads:
https://vborg.vbsupport.ru/showthrea...light=includes https://vborg.vbsupport.ru/showthrea...light=includes https://vborg.vbsupport.ru/showthrea...light=includes After reading those, I still don't know how to do it and get it to work. Can somebody give me some help on how to get a php file to be included at the top of each page of the forum? Any help is appreciated. Thanks! |
You can add its contents into your "phpinclude" template
|
Quote:
|
I dont know if "include" or "require" would work (I guess so though) so I meant adding the code directly in phpheader template. But it doesnt matter if you include or require either because tecnically they are not different then adding the code directly. If you have some PHP knowledge you can also convert the program to a "function", add it to functions.php and call it inside the template or global.php either..
If you want the program to be parsed you have to use either way even if it's a long program. But being a long program doesnt effect the performance: everytime your "any" vbulletin script is parsed "functions.php" with over 2500 lines of code is included in every run.. ;) |
I've tried to include the file that has the code in it, but it does work. It sounds like your saying that should work. Did I do it wrong? I just used the normal include statement:
PHP Code:
|
I guessed so but if it's not working then it means my guess was wrong. So use the other methods.. You dont need to insist on including because as I said before inclusion is not different than adding the entire code inside your template.. In fact it is what your file does when it runs if you made an inclusion..
|
Quote:
What else can I try? I could do a lot of cool stuff if I can get the include statement to work. I really need something that will make it work, or will work the same way because I have other files that are outputting their data to a file and I need to tell my forums to grab that info and slap it on the pages. Any ideas? |
Quote:
1- Add the entire code to phpinclude. As I said before you dont need to be scared because technically it's no different than adding a include("file.php") to your phpinclude template. 2- Convert your code to a function and add it at the end of inside function.php. Then you can call it as PHP Code:
3- Add you code to global.php. It also runs everytime any vb scripts runs, just like phpinclude template.Therefore you can try to add either the include statement or the entire code to global.php as well.. |
Quote:
PHP Code:
|
NTLDR that seemed to work, but it puts it at the very top of the page. Is there anyway to get it so I can do stuff with it. Like have stuff above it, etc. So that it's just another thing I can call up by doing something like "$stuff"?
I didn't really want it at the very top, but it's a step in the right direction. Any ideas? |
You could put something like $stuff = something; in global.php and then use $stuff in a template anywhere on the site.
|
Quote:
so if I put PHP Code:
I just wanted to make sure that was the exact code or if you were putting more emphasis on "like"? This is going to be KICK ASS! :D |
Sort of, but not exactly.
In your global.php file, you need to add a line like this: PHP Code:
Anyway, then in your templates, wherever you add $something, you will get the contents of the PHP file. This is essentially the third option that Logician gave: Quote:
|
That seems to do the same thing. I didn't even call it in the template. As soon as I put it in the global file it called it and put it above the header.
Anything else? :( |
OK, for some reason I was thinking that your included file would be performing some sort of function rather than just outputting data.
I thought about it some more, and I'm not sure how you would get the output "on demand" as you suggest, without adding it to the vBulletin code -- assuming that the PHP file you want to include echoes something back. Why not just edit the files so that they "store" their output in a variable, then put the file in the global.php as I suggested (or the phpinclude template as Logician suggested) and then just use that variable where you need the output? I can't think of any other way to do it. I think that to achieve what you're trying to do, you're going to need to work with the code one way or another. |
Quote:
|
bump!
|
All times are GMT. The time now is 01:03 AM. |
Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|