Log in

View Full Version : Need help w/ PHP include statement in VB


mateo1221
06-19-2003, 04:37 PM
I'm kind of a newbie b/c I just installed VB on my site, but I need to create a new environment/global variable that I can reference throughout VB much like {picturesfolder} and such... which file do I modify to create a new variable like this? Thanks!

filburt1
06-19-2003, 04:50 PM
Those are replacements; you can create them in the Replacements (surprise ;)) section of the admin CP.

mateo1221
06-19-2003, 04:59 PM
ohhh... so maybe that's NOT what I want... the replacements basically just insert a set of code for the {REPLACEMENT} word? nice feature! VB get's better as I work through it...

OK, well then here's the REAL problem... attached is a PHP file that I want to include (using a PHP include statement :cool: ). It generates a random banner and displays it. I want to put it just above the section where it puts the "Name Of Your Forum" on the left and "Welcome back, Username" on the right.

What file do I need to modify to do this?? I was told it was "header" in the templates, so I modified that, inserted a table w/ a <?php include ('myfile.php'); ?> statement in it and it put the banner there, but it put it @ the VERY top of the page... ??? then when I removed the code, it did not remove the banner... I'm getting scared now... Plus, about half the time that you refresh any post or the forum index page, you get this PHP error:

Warning: Cannot modify header information - headers already sent by (output started at /home/clubvwof/public_html/forum/banner/banner.php:54) in /home/clubvwof/public_html/forum/admin/functions.php on line 1652

Line 1652 is a setcookie line... :mad: I'm lost

If anyone could be sooooo helpful as to take a look, I'd appreciate it... Our forum is HERE (http://www.clubvwoflouisville.com/forum). Thanks again!

mateo1221
06-19-2003, 05:32 PM
anyone? :paranoid:

filburt1
06-19-2003, 06:12 PM
It's only been half an hour, please wait much longer before bumping...

SmEdD
06-19-2003, 06:20 PM
Well I can't really explain how it's done but I will do my best.

First this is not in the header otherwise it will go on every page there is.

Second this file need to be added into index.php with a $callname.

Third you need to edit forumhome template and put the $callname in it where you want to locate it.

Or unless you want it in your header you have to do the file stuff in global.php and template header.

I don't really get where you exactly want to put it.

mateo1221
06-19-2003, 07:32 PM
I DO want it to go on every page in the forum... so should I do it in the header??? My problem is that when I edit anything in the header (even if I edit it @ the end of the header) whatever I insert ends up @ the TOP of the page... ???

If I create a variable called $banner in index.php, can I reference $banner in any of the forum php files? For instance, should I create a string variable like this?:

$banner = "include ('myfile.php');"

or something along those lines and then just add $banner wherever I need the banner script included?

I'd just like to insert it pretty much @ the top of the forum but below the title image and the UserCP, Register, etc buttons... somewhere in there... placement isn't ALL that important.

I'll play w/ all of the things you mentioned, but I am still kind of new to VB... what exactly do you mean by a $callname? Just creating my own variable?

THX!

mateo1221
06-19-2003, 09:24 PM
OK... got it fixed for the most part now... one last problem...

I have the SPOT I want and all and all of the repeats and errors are gone, but now I can't get the banner to come up @ all... :surprised:

Is this an illegal statement in the "header" template?:

<?php include ('banner/banner.php'); ?>

I know it's the right path b/c it worked before, but now it won't. The "header" template IS a part of a PHP file, correct???

Confused... :rolleyes:

SmEdD
06-20-2003, 12:35 AM
Ok first off the templates are html and cannot use php.

Open global.php

Find:

eval("\$headinclude = \"".gettemplate('headinclude')."\";");
eval("\$header .= \"".gettemplate('header')."\";");
eval("\$footer .= \"".gettemplate('footer')."\";");

Replace with:

eval("\$headinclude = \"".gettemplate('headinclude')."\";");
$banner = include ('banner/banner.php');
eval("\$header .= \"".gettemplate('header')."\";");
eval("\$footer .= \"".gettemplate('footer')."\";");

Save and upload.

Then in header template put $banner where you want it to come up.

mateo1221
06-20-2003, 06:38 PM
Getting somewhere now, but I have yet another question...

This just creates the VARIABLE between the headinclude and the header, correct? It doesn't actually put the information there or parse any text. I realized this when I did what you suggested above and the banner.php script appeared @ the top of the page. How, now, do I fix THIS issue? Any suggestions?

Thanks for your help... we're getting SOMEWHERE... :classic:

SmEdD
06-20-2003, 09:04 PM
Add me to your MSN or ICQ

MSN = smedd@nocturnal-soldiers.com
ICQ = 309001488

mateo1221
06-21-2003, 03:02 AM
Done... I sent a request for you to add me to your ICQ... I'm #236832167... thx for you help!!!

Cloudrunner
06-21-2003, 06:25 AM
Actually, it does parse the file that was included....thus the eval'd statement below it that converts the variable into something the templates can read ;)

mateo1221
06-21-2003, 05:54 PM
but in the PHP file, you're not actually INSERTING any text, right? you're just defining $banner to be an include statement, then you insert $banner in the header...

anyway, could someone take a look @ our forum here (http://www.clubvwoflouisville.com/forum/) and see if you can tell me why the banner actually appears @ the top and a 1 is inserted in the place where $banner is placed (inside the small blank table @ the top)??? Thx in advance!

mateo1221
06-21-2003, 05:58 PM
and does anyone know what this might mean??? :

Warning: Cannot modify header information - headers already sent by (output started at /home/clubvwof/public_html/forum/banner/banner.php:54) in /home/clubvwof/public_html/forum/admin/functions.php on line 1652

mateo1221
06-23-2003, 03:55 PM
Here's a question...

what does the template PHPINCLUDE do?

it says something about require('yourheader.html'); and ob_start and ob_end_clean (which I have seen before) but the ENTIRE file is commented out...

Is THIS what I'm looking for?!?!?! :confused:

SmEdD
06-24-2003, 04:33 AM
PHPINCLUDE = Calling for a files contents. I was gonna try to show you a diffrent way useing template but were never on ICQ at same time.