PDA

View Full Version : php header includes etc


35mm
08-01-2011, 01:02 PM
Just wondering if there is a definitive guide for including php files and code in vb4.x or if someone can explain. Right now I am trying to include a php header file. I have followed the instructions here https://www.vbulletin.com/docs/html/main/templates_externalfiles but can't get it working.

Here's what I have tried in plugins under the global_start hook;

ob_start();
$includedphp = ob_get_contents('/home/site/public_html/inc/header-inc.php');
vB_Template::preRegister('header',array('includedp hp' => $includedphp));
ob_end_clean();



and I have put {vb:raw includedphp} in the header template.
I have also tried {vb:raw global.includedphp}

This doesn't work. The site's header include consists of plain html with inline php echos. I have tried changing it to a single php echo but still no good.

Any advice would be greatly appreciated!

kh99
08-01-2011, 02:40 PM
I think you want this:

ob_start();
include('/home/site/public_html/inc/header-inc.php');
$includedphp = ob_get_contents();
vB_Template::preRegister('header',array('includedp hp' => $includedphp));
ob_end_clean();


Then {vb:raw includedphp} should work in the template.

35mm
08-06-2011, 10:59 AM
Thank you very much for that. It now works.