PDA

View Full Version : Adding PHP include file to header


myadsl
05-07-2008, 11:43 PM
Hi there

Can you please point me in the right direction on how to add a PHP include file in our forum header?

I want to add <?php include('{Path to file}');?> to our header. I have a PHP file which produces some test output which I want to display?

Any help will be much appreciated.

Kirk Y
05-08-2008, 01:00 AM
You'll have to utilize the plugin system and hook at global_start.

http://www.vbulletin.com/docs/html/templates_externalfiles

myadsl
05-08-2008, 06:39 AM
Solved it thanks...

CypherSTL
05-08-2008, 08:32 AM
Solved it thanks...
How did you solve it?

I'm having a problem with one of my plug-ins that isn't working properly.

Plugin Code

ob_start();
require_once('sigStrip.php');
$sigStripPHP = ob_get_contents();
ob_end_clean();
And I'm calling this code in the postbit_legacy template using the following:
$sigStripPHP

A vB guy told me to use $globals['sigStripPHP'] to call it, but I get errors when I go to do that and no posts display.

The sigStrip.php for now just contains the following:

<?php
echo "Test";
?>
Thanks!

Kirk Y
05-08-2008, 09:51 AM
No, you would call it with $sigStripPHP.

CypherSTL
05-08-2008, 10:23 AM
No, you would call it with $sigStripPHP.
I've tried that as well. It almost seems it's not even executing / including the phpfile when I do that, but when I check Debug mode, it does include it.

It just isn't displaying any of the output, in this case, the word "Test".

Marco van Herwaarden
05-08-2008, 10:30 AM
Which hook location are you using for the plugin?

CypherSTL
05-08-2008, 07:21 PM
Which hook location are you using for the plugin?
global_start

Kirk Y
05-08-2008, 08:28 PM
Just to cover all the bases, you are using $sigStripPHP in a template, right? If so, which?

CypherSTL
05-08-2008, 08:32 PM
Just to cover all the bases, you are using $sigStripPHP in a template, right? If so, which?
Yes. I have it entered into the postbit_legacy under the signature.

Kirk Y
05-08-2008, 08:36 PM
Ah ha. The hat drops. You need to move your hook's location from global_start to postbit_display_start.

Because the postbits are output by a function, you're having a scope issue -- $sigStripPHP does not exist.

CypherSTL
05-08-2008, 11:14 PM
Ah ha. The hat drops. You need to move your hook's location from global_start to postbit_display_start.

Because the postbits are output by a function, you're having a scope issue -- $sigStripPHP does not exist.
Thanks. Changing the hook location fixed it.