![]() |
PHPInclude Variables in Formbit Templates
The variables in PHPInclude do no show up in any of the formbit templates where I have inserted them (though they work fine on other templates).
The search feature referenced me to a post which suggested that I add $session to a specified line in the functions.php file. This, however, seems to have already been done with 2.3.0 but to no affect. Any help on forcing PHPInclude variables to be displayed in the formbit templates would be appreciated. Thanks. |
bit variables areoften called within functions.
and functions just can use variables from other part of the script (phpinclude her) if you made em global in that function Basic php knowledge |
Quote:
Can you please provide an example? |
Check out http://www.php.net/manual/en/languag...bles.scope.php for what he's talking about.
|
Quote:
Thank you for the link. I have a better understanding of globals within functions but at the same time, I'm still unsure as to how to apply this in order for the fuction to show on postbit. Are you saying I need to put global on fuctions made in phpinclude? My code in the external script isn't incased in a fuction syntax. All it does is echo out html based on whether or not if this is the first instance of the code being applied. A real world example using this problem would be most helpful. Thanks. |
Put simply, there's nothing you can do without editing how phpinclude itself works.
|
Quote:
Would you be willing to dilvulge a little more detail? Perhaps I can ask a programmer who is knowledgable with PHP. All I would need to know is what areas need to be edited. |
I am knowledgable in PHP considering I have developed a full emergency messenging system in it at NASA. phpinclude is eval'ed after bit templates, which is why it does not have acccess to the bit templates (which are eval'ed before it).
|
Quote:
|
You can't without rewriting a significant chunk of gettemplate() to:
1. See if a flag is set 2. If not, eval phpinclude and set it 3. Continue with normal gettemplate functions ...also removing it from (IIRC) global.php. |
Quote:
:disappointed: |
Quote:
|
Quote:
<? echo "TEST TEST TEST<br><br>"; ?> Here is what I added to the PHPInclude Template: ob_start(); require("../test.php"); $testing = ob_get_contents(); ob_end_clean(); At the forumhome_forumbit_level1_nopost template, I simply added this at the top: $testing All this does is echo out TEST TEST TEST above the categories. The problem is that the $test variable does not display in any of the formbit templates when viewed on a web browser. According to Filburt, I have to do some extensive modification in one of the php files included with VBulletin just to get this one simple feature working. |
I thought we were talking about a variable scope problem here...
|
Quote:
I apologize if I somehow misrepresented my problem. Did my above example help to clear things up? Let me know... |
Your problem is related to your code in phpinclude. If you add $testing = "Test 1 Test 2 Test 3"; to phpinclude template then use $testing in the forumhome_forumbit_level*.* templates you'll be fine. So it is not phpinclude variable not showing in forumhome_forumbit_level* templates, it is your variable not getting a approprite value in the phpinclude.
|
Quote:
I'm trying out your above example but having a little trouble. Here is what I put into the phpinclude template: ob_start(); $testing = "TESTING 1 2 3"; ob_end_clean(); With my limited knowledge of php, I'm sure it is just syntax issues or some other problem that is right under my nose. Thanks for your help. |
Quote:
PHP Code:
If you can't get value of $testing variable displayed, this would be because you put it in the wrong template. Please notice that there are 4 of forumhome_forumbit_level*.* templates and not all of them are parsed in your forum home. Which one or ones are used depends on different conditions so try to to put the variable in each or one by one to understand how and when they are displayed. Also if you want a advise, considering the fact that you use this variable in only forumhome_forumbit_level*.* templates, you don't need to put it in phpinclude template. Just put your variable in index.php right after require('./global.php'); I personally do not fancy phpinclude solutions much as they waste unnecessary server power/memory. |
forumhome_forumbit_level*.*
Pal, these templates are just called by function makeforumbits in index.php, so as i stated in my first post, he has to add global $testing; to that function, but i think nobody listens to me.... |
Quote:
PHP Code:
PHP Code:
|
Guys, how can I include php in every template I need?
I mean require and so on. Tried a hack called PHP Embed - it does not works for me. Sos! |
Please start your own thread, don't hijack somebody else's...
|
Quote:
With the usefulness of the simple example now past, I attempted to add in some php code in the phpinclude template but it seems I pushed my luck a bit too far. It was a basic count script to display TESTING 123 three times: $testing = ($i = 0; $i < 3) { echo "TESTING 123" } I know this breaks the no echo rule for phpinclude but what would be a way to incorporate external php in this manner? Thanks again. |
that is no valid php code here.
You should really learn to code php correctly before trying to hack vb. There are good books out to learn the basics of php, you won't get it by just try and whenever there is an error ask here... |
Quote:
I have written some php code on an external file that DOES WORK. My only problem here as I see it, is that I'm having difficulties implementing it within formbit templates. I have created similar variables all linked to other php files within phpinclude which work correctly on the header and footer templates. Formbit, as I'm lead to believed, works differently and that is now my only hurdle. No, I'm certainly no expert in PHP, but little examples are all the push I need here. Thanks in advance. |
PHP Code:
to write valid php it should look somehow like that: PHP Code:
|
Quote:
|
bump
|
All times are GMT. The time now is 04:58 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:
|