There are other articles out there on variables, templates, etc on vBulletin 4. This is a simple example of including an external PHP files like you used to be able to do here:
Hook Location: What area of the forums you want this variable to appear. Don't know where? Use global_start
Title: Give it a title
Execution order: Your choice
Plugin PHP Code:
Code:
ob_start();
require_once('LOCATION OF EXTERNAL FILE');
$php_include = ob_get_contents();
ob_end_clean();
vB_Template::preRegister('TEMPLATE YOU ARE USING',array('php_include' => $php_include));
Step 2: You will have to figure out these two entries for yourself: LOCATION OF EXTERNAL FILE & Hook Location
To give you an example of what you should use is that if you want to display your external PHP file on your Forum's Home. Then replace these two with these values:
Hook Location with forumhome_start
TEMPLATE YOU ARE USING with FORUMHOME
Keep in mind that global_start will still be acceptable, but it's extra loading time where it's not needed. Therefore choosing the optimum hook location is better for your performance overall.
Step 3: Visit the Style Manager -> TEMPLATE YOU ARE USING and place the variable in your style where you want it. You will have to use the new format.
Code:
{vb:raw php_include}
That's it - Pretty simple; see?
Notes, If you want to:
Include this PHP file in multiple templates then preRegister it for the multiple templates:
Code:
vB_Template::preRegister('TEMPLATE YOU ARE USING',array('php_include' => $php_include));
vB_Template::preRegister('TEMPLATE YOU ARE USING 2',array('php_include' => $php_include));
Yes, I'm using global_start. Using a full server path I can get the forum to work (previously I was getting a blank forum page).. but nothing is being included. And yes, I'm sure the file is where it is supposed to be.
i am having the same issue, did you ever find a solution to this problem Centrix ? or anybody else who could help ?
Quote:
Originally Posted by Centrix
I tried this, but it made my forum crash miserably. I had to restore a database backup in order for it to work again.
I made a custom template and I dont know which hook location to use for this...? if I use global start my site and forum (site is linked to the forums) is just the contents of the php file im trying to include.
vB_Template:reRegister('TEMPLATE YOU ARE USING',array('php_include' => $php_include));[/code]
Step 2: You will have to figure out these two entries for yourself: LOCATION OF EXTERNAL FILE & Hook Location
To give you an example of what you should use is that if you want to display your external PHP file on your Forum's Home. Then replace these two with these values:
Hook Location with forumhome_start
TEMPLATE YOU ARE USING with FORUMHOME
The included page shows up but it's showing on every page. I used the parse_template hook. Do I need to include anything else to only show one a specific page?