PDA

View Full Version : How to add PHP in a custom template file?


CampinCarl
02-24-2011, 11:23 AM
I'm trying to make dynamic pages by using the tutorial on this page.

https://vborg.vbsupport.ru/showthread.php?t=228112

I've gotten it to work and all, but the only problem I have is adding PHP to the page. I've followed everything here.

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

What I did was I enabled plugins / hooks. I made a new plugin, global_start, etc. I dragged a file called test.php into my forum root, and I inserted the following code into the plugin.

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

I went back to my template and added {vb:raw includedphp}, and nothing happened. What am I doing wrong?

tonyvh2
02-24-2011, 11:58 AM
try:

- filling in the complete path for example /complete/path/etc/test.php
- register template you are using where name of the template is "yourtemplate"

like this:

ob_start();
require_once('/complete/path/etc/test.php');
$includedphp = ob_get_contents();
ob_end_clean();
vB_Template::preRegister('yourtemplate',array('inc ludedphp' => $includedphp));

CampinCarl
02-24-2011, 01:03 PM
Thank you!