PDA

View Full Version : PHP Include in Header


Marc.F
10-17-2007, 10:27 AM
Hi Guys..

I am in the process of creating a skin for my forum but i have ran into a problem.

My problem is:

Can i use a PHP include such as:


<?php
include('../../core.php');
top('Forum');
?>


in my header template (not headerinclude).

Cheers,
Marc

Marco van Herwaarden
10-17-2007, 10:40 AM
No, you can not use PHP in templates, they are only HTML.

You can however create a plugin with your PHP-code, assign the output to a variable and use that variable in your template.

Marc.F
10-17-2007, 11:07 AM
Ill give that a try and post back! Thanks!

By the way, what would my Hook Location be? The header?

--------------- Added 1192626390 at 1192626390 ---------------

Anyone?! Please!!

Analogpoint
10-17-2007, 02:20 PM
Use global_start if you want it to be available on all pages.

Marc.F
10-17-2007, 02:26 PM
Ok, thanks but how do i put this in my template?

As you can probubly guess, im a beginner with vBulletin code!

Analogpoint
10-17-2007, 02:30 PM
Plugin on the global_start hook:
$myheader = '<h1>My Header Here</h1>';

Then near the top of your header template:
<!-- logo -->
<a name="top"></a>

$myheader

Marc.F
10-17-2007, 02:46 PM
Thanks,

I have created a new product (called 'nav') and added a plugin within (called 'navshow') it's hook location is global_start... In plugin 'navshow i have:

$navig ='<?php
include('../../../core.php');
top('Forum');
?>';


Also, in my header template i have $navig.

It still isnt working, what am i doing wrong :(

Thanks in advance!

Analogpoint
10-17-2007, 02:52 PM
Change your plugin code to:
ob_start();
include('../../../core.php');
top('Forum');
$navig = ob_get_clean();

Dismounted
10-18-2007, 06:01 AM
<a href="http://www.vbulletin.com/docs/html/templates_externalfiles" target="_blank">http://www.vbulletin.com/docs/html/t..._externalfiles</a>

Marc.F
10-18-2007, 08:09 AM
http://www.vbulletin.com/docs/html/templates_externalfiles

Thanks! Just what i was looking for!

suttercain
11-23-2007, 07:17 PM
Hi guys,

I foollowed the direction to this post as well as the official documentation and I can't seem to get it to work.

I went to "Plugins & Products" and created a new plugin. The product was selected to vBulletin, I set the hook location as vBulletin General > global_start. I left the Execution order at 5 (i have no idea what this is) and I added ob_start();
include('http://www.supermandatabase.com/header.php');
$includedphp = ob_get_contents();
ob_end_clean(); to the Plugin PHP Code box.

I then went and placed $includedphp into the header box on my template. Nothing... does not work. What can I do?

Thanks

Analogpoint
11-23-2007, 09:00 PM
You need to include a file on your server

include('./header.php');

or

include('/path/to/the/file/header.php');

suttercain
11-23-2007, 11:26 PM
Thanks for the reply.

I changed

ob_start();
include('http://www.supermandatabase.com/header.php');
$includedphp = ob_get_contents();
ob_end_clean();


to


ob_start();
include('/home/superman/public_html/header.php');
$includedphp = ob_get_contents();
ob_end_clean();


and I also tried


ob_start();
include('./header.php');
$includedphp = ob_get_contents();
ob_end_clean();


I didn't change any of the other things I listed above. Still no luck...

Any other suggestions? Thanks again.

SC

Analogpoint
11-24-2007, 02:59 AM
Try this temporarily, and see if it outputs the contents of the header file
ob_start();
require_once('/home/superman/public_html/header.php');
$includedphp = ob_get_clean();
echo '<hr>before';
echo $includedphp;
echo 'after<hr>';
die;

suttercain
11-24-2007, 03:09 AM
Nada.. nothing showed up in the header. I wonder if it's a pathing issue (I ran a php script and verified the correct path though) or something else?

Analogpoint
11-24-2007, 03:15 AM
Nada.. nothing showed up in the header.

Nothing at all showed up?

suttercain
11-24-2007, 03:28 AM
Nope. You can see the bulletin board here
supermandatabase.com/forums

I even triple checked to make sure that the plugin were turned on. I tried renaming the variabl and placing it into the header. Nothing... I know a lot of php and this has me scratching my head.

SC

EDIT: Sorry, I didn't mean "Nothing" showed up. I meant nothing showed p that we set in the plugin variable.

--------------- Added 1195937083 at 1195937083 ---------------

So am I Just S.O.L. then?