Not quite sure how to add PHP include statements anymore - comments/recommendations welcome.
How do I add PHP includes?
Collapse
X
-
The phpinclude templates are no longer used. You just create a new Plugin at the global_start and/or global_complete hook and put your PHP code in there.Comment
-
AdminCP -> Plugin System -> Add New Plugin
For the hook location select 'parse templates'
Then enter a title so you can easliy identify it if you ever want to change it
For the PHP code, enter the following:
PHP Code:eval('$varname = "' . fetch_template('templatename') . '";');
You can now call the code from your template in any other template by using $varname or whatever you named the variable in the PHP codeComment
-
Thanks for the reply - much appreciated.
So...if I wanted to include a file called "navbar" I would use the following code?
Code:[COLOR=Black][COLOR=#000000][COLOR=#007700]eval([/COLOR][COLOR=#dd0000]'$varname = navbar' [/COLOR][COLOR=#007700]. [/COLOR][COLOR=#0000bb]fetch_template[/COLOR][COLOR=#007700]([/COLOR][COLOR=#dd0000]'navbar.php'[/COLOR][COLOR=#007700]) . [/COLOR][COLOR=#dd0000]'";'[/COLOR][COLOR=#007700]); [/COLOR][/COLOR][/COLOR]
I suspect that I've misunderstood the above.
Comment
-
Close But it should be:
PHP Code:eval('$navbar = "' . fetch_template('navbar') . '";');
Last edited by vbStartup; Sun 9 Oct '05, 9:01am.Comment
-
You can't include directly in the templates.
Add a new global_start plugin and use the following code:
PHP Code:ob_start();
include_once(‘/path/to/file.html’);
$included_file = ob_get_contents();
ob_end_clean();
Best Regards
Colin Frei
Please don't contact me per PM.Comment
-
You will still have to create a new plugin To get the output of your included content to appear where you want them to in the templates, then you'll have to use some output buffering and capture them in a template.
PHP Code:ob_start();
include('navbar.php');
$navbar = ob_get_contents();
ob_clean();
include('footer.php');
$footer = ob_get_contents();
ob_end_clean();
Ah Colin beat meComment
-
Add a new global_start plugin
Normally I'd include that code in the "phpinclude_start" in 3.0, but since upgrading to 3.5, I have no idea what the procedure is - I know there's a "plugin system" but have no idea how it's supposed to be used.
Comment
-
No problem Goto your
AdminCP > Plugin System > Add New Plugin
Give it a name and select 'global start' as the hook location, and input the code above, adjusted to your needs. Mark the plugin as active and Save it.
Also, make sure that you have plugins turned on globally in your vBulletin Options.Best Regards
Colin Frei
Please don't contact me per PM.Comment
-
Look at the below screenshot
Ah... Colin explained it before I finished the screenshot.Comment
widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
Comment