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));
Can someone help me ? When I run plugins everywhere are white pages...
It's hard to say without seeing exactly what you're doing, but it sounds like there's an error in the plugin you're trying to run. Have you checked the error logs (if you have them available)?
Warning: require_once(/szatek/vb/nowosci.php): failed to open stream: No such file or directory in ..../includes/class_bootstrap.php(103) : eval()'d code on line 2
Fatal error: require_once(): Failed opening required '/szatek/vb/nowosci.php' (include_path='.:/usr/local/lib/php') in /home/p2y/domains/p2y.eu/public_html/szatek/vb/includes/class_bootstrap.php(103) : eval()'d code on line 2
Warning: require_once(/szatek/vb/nowosci.php): failed to open stream: No such file or directory in ..../includes/class_bootstrap.php(103) : eval()'d code on line 2
Fatal error: require_once(): Failed opening required '/szatek/vb/nowosci.php' (include_path='.:/usr/local/lib/php') in /home/p2y/domains/p2y.eu/public_html/szatek/vb/includes/class_bootstrap.php(103) : eval()'d code on line 2
It appears this file is missing or doesn't have the correct permissions: /szatek/vb/nowosci.php