PDA

View Full Version : Include PHP file in Footer?


jribz
09-24-2005, 09:20 PM
Is there a simple way to include a php file in the footer of the forums?

Thanks

Blaine0002
09-24-2005, 10:19 PM
<?php include("file.php"); ?>

jribz
09-24-2005, 10:46 PM
<?php include("file.php"); ?>Sorry, I meant from a template without editing a php file. That would work in a php file but not from a template, well, at least I can't get it to work from a template.

Blaine0002
09-24-2005, 11:30 PM
you want a template to load up another template?

jribz
09-25-2005, 12:11 AM
you want a template to load up another template?No, I want the template to call a php file and display it, the php file basically has links which dynamically change, similar to an ad script.

Blaine0002
09-25-2005, 12:29 AM
hmm the include function should work then..

jribz
09-25-2005, 12:35 AM
hmm the include function should work then..Well I recall when doing something similar I had to use phpincludestart however this is no longer an option in 3.5.... :ermm:

evenmonkeys
09-25-2005, 02:18 AM
I've been trying to get help on this as well and no one seems to care. =P You are not able to put php directly into the templates. You are given two options. Create a php file that calls for a template aka the footer. Or you may create a plug-in that you'd put before or after the footer. I can't go too far into detail, but maybe that'll help you a little bit. I'm trying to put php into my header, but I'm not doing so well.

Adrian Schneider
09-25-2005, 02:28 AM
Try hook: global_start
ob_start();
include('yourfile.php');
$variable = ob_get_contents();
ob_end_clean();

Then you should be able to use $variable in your templates.

[ I'm not sure if this is the correct hook, but it should work ]

evenmonkeys
09-25-2005, 08:56 PM
What exactly would I specify in the template then? How would I call for it?

I'm confused. I made a plugin with what you gave. I changed the source appropriately. Then what do I put in my header template to call for that hook? Do I need to create a new template? Please be detailed in your answer. I'd really appreciate it.

Andreas
09-25-2005, 09:20 PM
Place $variable (or however you called it) in Template footer (or header if you want it there) where you want to have the output from your include script displayed and you're done.

evenmonkeys
09-25-2005, 09:24 PM
Thank you so much both of you. It works.

jribz
09-25-2005, 10:29 PM
OK I can get a file included this way, thank you....

Now I have another question, as it seems it will not allow me to include a file that has a script in it, . . . thinking about it though I probably just need to add the script to the code in the created plugin and then call it.

Hopefully I just answered my question. :ermm:

EDIT: nope :speechless:

Is there a detailed walkthrough on adding a plugin manually, I am trying to add some code, which is basically a php file that calls information from several other files, hoping to be able to use a $variable to include it.

As I said above, I can get it to work if it's just a normal php file with no calls to other files, just can't seem to get anything to show up if it's a more complex file.

Thanks.

evenmonkeys
09-26-2005, 01:46 AM
Well, I'm not sure if this is going to help... but I'll show you exactly what I did.

*******************************

STEP ONE: The first thing I did was create the plug-in. The settings of the plug-in are below.

Name: Whatever
Hook Location: global_start
Plug-in PHP Code:
ob_start();
include('http://site.com/file.php');
$main_xb_nav = ob_get_contents();
ob_end_clean();
Active: Yes

*******************************

STEP TWO: After that, you'll need to create the php file. Inside the file, you can basically have whatever you want. In my case, it's just html. However, I have a simple script that calls for the date. IE: <?php echo date ('l, F dS Y'); ?>

*******************************

STEP THREE: After that, you'll need to call for the plug-in somewhere in the forums. All you need to input is the bolded part below. In my case, I used it in my header. Below is how I have it setup.

<!-- logo -->
<a name="top"></a>
<table border="0" width="$stylevar[outertablewidth]" cellpadding="0" cellspacing="0" align="center">
<tr>
<td align="center"><a href="$vboptions[forumhome].php$session[sessionurl_q]"><img src="images/logo.jpg" border="0" alt="$vboptions" /></a></td>
</tr>
</table>
<table class="navbarwrap" border="0" width="$stylevar[outertablewidth]" cellpadding="0" cellspacing="0" align="center">
<tr>
<td>
[b]$main_xb_nav
</td>
</tr>
<tr>
<td bgcolor="#666666" height="1"></td>
</tr>
<tr>
<td bgcolor="#868686" height="5"></td>
</tr>
</table>
<!-- /logo -->

*******************************


CONC: All I did was add that little bolded part, as well as define an area for it with the row and column commands. Otherwise, that's all I needed to do. Like I said, I'm not sure if that's what you need, but that's what I did. If I'm on the right track, but you have a few questions, feel free to AIM me: xinnyburt.

It works for me just fine. The PHP is working as well.

Adrian Schneider
09-26-2005, 01:59 AM
If you were only going to insert the date you didn't need to create a seperate file. Could have just done something like:

$main_xb_nav = date("l, F dS Y');

jribz
09-26-2005, 04:27 AM
SirAdrian he was inserting a customized navbar for his site in addition to the time, in fact the time might have just been to see if script would work...

xYarub, I have done everything you listed, the only problem is, if there is a <php include in the file I am calling from the plugin, it basically ignores the entire plugin.

I can get it to work with just html, I think the problem getting the file I want to work is that it calls for some server settings as well as another file on the server. Basically, the php file I am including gather information from the server and another file, so maybe that is why it comes up blank. I just don't know. :ermm:

evenmonkeys
09-27-2005, 08:53 PM
I am actually unsure of how to help you. It sounds like you're doing it all right. Sorry. =\

jribz
09-27-2005, 08:58 PM
I am actually unsure of how to help you. It sounds like you're doing it all right. Sorry. =\Thanks anyhow, still looking for a solution though, so if any coders out there read this let me know if you have any ideas. :ermm:

Peace_Hope
10-22-2005, 01:32 PM
xYarub,

Thanks a ton!! That works awesome