The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
Include PHP in an advert
Hey I asked the following question over at vBulletin.com:
Quote:
Basically, all I need to do is place an include to one php file in an advert. I don't mind hard coding the reference into the remplate if necessary, rather than going through the ad system. Thanks |
#2
|
|||
|
|||
You should be able to do something like this: create a plugin using hook location parse_templates, and code like this:
Code:
ob_start(); include "path/included_file.php"; $included_file = ob_get_contents(); ob_end_clean(); vB_Template::preRegister('template_name', array('included_file' => $included_file)); And then in the ad template, use {vb:raw included_file}. Of oucrse you need to use the actual path and file name, use the right template name for the ad location, and you can change 'included_html' to comething else if you want. |
#3
|
|||
|
|||
Thanks for the suggestion, I've given it a go but it doesn't seem to work. Would you be able to sanity check what I've done?
1. I setup a new plugin with the following details: Product: vBulletin Location: parse_templates Name: included_html Code: Code:
ob_start(); include "/path/to/file.php"; $included_file = ob_get_contents(); ob_end_clean(); vB_Template::preRegister('navbar', array('included_file' => $included_file)); Location: Below Navbar Ad HTML: Code:
{vb:raw included_html} What am I missing? --------------- Added [DATE]1365242536[/DATE] at [TIME]1365242536[/TIME] --------------- Ok, I can see my ad code should probably be: Code:
{vb:raw included_file} |
#4
|
|||
|
|||
Quote:
Try using 'ad_navbar_below' as the template name (in place of 'navbar'). |
#5
|
|||
|
|||
No worries. It's still not working though :-/
Am I asking for an extra level of complexity here, I don't mind putting the variable directly into the template, would that be easier? |
#6
|
|||
|
|||
You could certainly try that. So then you *would* use 'navbar' for the template name.
If that doesn't work, try temporarily adding a line to the plugin, like this: Code:
ob_start(); include "/path/to/file.php"; $included_file = ob_get_contents(); ob_end_clean(); $included_file = "Included File"; vB_Template::preRegister('navbar', array('included_file' => $included_file)); and see if that shows up. |
#7
|
|||
|
|||
So I switched the template to 'navbar' and added in the {vb:raw included_file} line to the template directly and that worked!
I also tried your debug code (while using the ad too), but it had no effect. I think I'll stick to putting the code directly into the template - but if you have any more suggestions why the original attempt failed I'd be interested in learning more. Thanks! |
#8
|
|||
|
|||
I don't see why it didn't work - I'd have to run some tests. But if you have it working, I guess it doesn't really matter which template you had to edit.
|
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|