vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   PHPInclude Variables in Formbit Templates (https://vborg.vbsupport.ru/showthread.php?t=53137)

Boeman 05-19-2003 08:35 PM

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.

Xenon 05-20-2003 09:11 AM

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

Boeman 05-20-2003 02:31 PM

Quote:

Today at 11:11 AM Xenon said this in Post #2
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


Can you please provide an example?

filburt1 05-20-2003 02:50 PM

Check out http://www.php.net/manual/en/languag...bles.scope.php for what he's talking about.

Boeman 05-20-2003 05:58 PM

Quote:

Today at 04:50 PM filburt1 said this in Post #4
Check out http://www.php.net/manual/en/languag...bles.scope.php for what he's talking about.

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.

filburt1 05-20-2003 05:58 PM

Put simply, there's nothing you can do without editing how phpinclude itself works.

Boeman 05-20-2003 06:09 PM

Quote:

Today at 07:58 PM filburt1 said this in Post #6
Put simply, there's nothing you can do without editing how phpinclude itself works.

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.

filburt1 05-20-2003 06:22 PM

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).

Boeman 05-20-2003 06:28 PM

Quote:

Today at 08:22 PM filburt1 said this in Post #8
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).
So in basic terms, what do I need to do to get my phpinclude functions to evaluate along with the formbit_level_1 template? I looked around various hacks listed here but could not find one that allows this.

filburt1 05-20-2003 06:31 PM

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.

Boeman 05-20-2003 06:38 PM

Quote:

Today at 08:31 PM filburt1 said this in Post #10
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.


:disappointed:

Logician 05-20-2003 06:59 PM

Quote:

Today at 10:28 PM Boeman said this in Post #11
So in basic terms, what do I need to do to get my phpinclude functions to evaluate along with the formbit_level_1 template? I looked around various hacks listed here but could not find one that allows this.
Why don't you post your code that fails (together with your template modification) so that we can all see which variables you are trying to parse and where exactly?

Boeman 05-20-2003 08:46 PM

Quote:

Today at 08:59 PM Logician said this in Post #12
Why don't you post your code that fails (together with your template modification) so that we can all see which variables you are trying to parse and where exactly?
To make this as simple as possible, here are the contents of my external php file, test.php:

<?
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.

filburt1 05-20-2003 09:28 PM

I thought we were talking about a variable scope problem here...

Boeman 05-20-2003 09:32 PM

Quote:

Today at 11:28 PM filburt1 said this in Post #14
I thought we were talking about a variable scope problem here...

I apologize if I somehow misrepresented my problem. Did my above example help to clear things up? Let me know...

Logician 05-20-2003 09:39 PM

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.

Boeman 05-21-2003 12:23 AM

Quote:

Yesterday at 11:39 PM Logician said this in Post #16
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.

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.

Logician 05-21-2003 05:14 AM

Quote:

Today at 04:23 AM Boeman said this in Post #20
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.

You don't need ob_start(); ob_end_clean(); part. Simply putting this line:

PHP Code:

$testing "TESTING 1 2 3"

will do the trick.

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.

Xenon 05-21-2003 10:35 AM

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....

Logician 05-21-2003 11:47 AM

Quote:

but i think nobody listens to me....
ok before Xenon gets angry let's listen to him: :glasses: So edit index.php, find:

PHP Code:

global $bbforumview

After that add:
PHP Code:

global $testing


gmarik 05-21-2003 01:56 PM

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!

filburt1 05-21-2003 03:04 PM

Please start your own thread, don't hijack somebody else's...

Boeman 05-22-2003 03:17 AM

Quote:

Yesterday at 01:47 PM Logician said this in Post #20
ok before Xenon gets angry let's listen to him: :glasses: So edit index.php, find:

PHP Code:

global $bbforumview

After that add:
PHP Code:

global $testing


As per your instructions (and Xenon's) I was able to display some text using the variable. Thank you both.

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.

Xenon 05-22-2003 01:55 PM

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...

Boeman 05-22-2003 02:13 PM

Quote:

Today at 03:55 PM Xenon said this in Post #24
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...


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.

Xenon 05-22-2003 02:17 PM

PHP Code:

$testing =

(
$i 0$i 3) {

echo 
"TESTING 123"



this code has more than one error in just 4 lines, so don't tell me that would work somewhere else.

to write valid php it should look somehow like that:

PHP Code:

for ($i 0$i 3$i++) {

echo 
"TESTING 123";




Boeman 05-22-2003 02:38 PM

Quote:

Today at 04:17 PM Xenon said this in Post #26
PHP Code:

$testing =

(
$i 0$i 3) {

echo 
"TESTING 123"



this code has more than one error in just 4 lines, so don't tell me that would work somewhere else.

to write valid php it should look somehow like that:

PHP Code:

for ($i 0$i 3$i++) {

echo 
"TESTING 123";




I wasn't actually referring to that block of code in my last post but nonetheless, it still doesn't work in phpinclude. How do you get that to work correctly in phpinclude so I can use it in formbit templates?

Boeman 05-26-2003 09:38 PM

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
  • Page Generation 0.01365 seconds
  • Memory Usage 1,827KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (9)bbcode_php_printable
  • (14)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (28)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete