Quote:
Originally Posted by slo_chewie
This has been working on my forum using local php invocation code.
I do get 3 mysql errors every hour that I haven't been able to figure out though. The mysql errror always gets reported as unregistered user so I think it may be spider related. The mysql error hasn't been causing any problems though. Just annoying getting the email about it.
Product: vBulletin
Hook Location: global_start
Title: OpenX
Execution Order: 5
Plugin PHP Code:
Code:
$tz = date_default_timezone_get();
define('MAX_PATH', '/home/website/openx');
if (@include_once(MAX_PATH . '/www/delivery/alocal.php')) {
if (!isset($phpAds_context)) {
$phpAds_context = array();
}
$phpAds_raw = view_local('', 0, 3, 0, '', '', '0', $phpAds_context, '');
}
date_default_timezone_set($tz);
Then add $phpAds_raw[html] to your template where you want the banner ad to appear
|
Wanted to followup on this to help others trying to do the same thing.
My goal was to have OpenX capture the vbulletin $forumid into the "source" parameter, so that I could serve different ads to different forums based on the delivery options in openX. This turned out to be pretty simple.
1. Configure your "local mode" invocation code via OpenX. Put $forumid in the source box so it will show you where in the php openX expects the forumid. The automated generated bannercode should look something like the following. You MUST remove the single quotes from around $forumid ( change
'$forumid' to
$forumid ).
Code:
<?php
//<!--/* OpenX Local Mode Tag v2.6.3 */-->
// The MAX_PATH below should point to the base of your OpenX installation
define('MAX_PATH', '/home/mysite.com/openx');
if (@include_once(MAX_PATH . '/www/delivery/alocal.php')) {
if (!isset($phpAds_context)) {
$phpAds_context = array();
}
// function view_local($what, $zoneid=0, $campaignid=0, $bannerid=0, $target='', $source='', $withtext='', $context='', $charset='')
$phpAds_raw = view_local('', 2, 0, 0, '', $forumid, '0', $phpAds_context, '');
}
echo $phpAds_raw['html'];
?>
2. Create a plugin in vBulletin ACP --> Plugins/Products --> Add New Plugin.
- hook location: global_start
- title: whatever
- execution order: 5 or whatever
Into the "Plugin PHP Code:", paste the invocation code, but without the php delimiters:
Code:
define('MAX_PATH', '/home/mysite.com/openx');
if (@include_once(MAX_PATH . '/www/delivery/alocal.php')) {
if (!isset($phpAds_context)) {
$phpAds_context = array();
}
// function view_local($what, $zoneid=0, $campaignid=0, $bannerid=0, $target='', $source='', $withtext='', $context='', $charset='')
$phpAds_raw = view_local('', 2, 0, 0, '', $forumid, '0', $phpAds_context, '');
}
echo $phpAds_raw['html'];
3. Put the variable $phpAds_raw[html] wherever you want this set of ad's to appear. It was important to remove the single quotes from around html for this to work. For example, my ad_navbar_below template now looks like this:
Code:
<center><div>
$phpAds_raw[html]
</div></center>
<br />
Hopefully this helps others trying to do the same thing. I am not a programmer and this could be dramatically wrong/improper, but it seems to be working great for me on vB 3.7.4 and with OpenX 2.6.3.
I welcome comments.