The following are some tips on using these two programs together, based on my own experience. It's expected that you know how to use phpadsnew 2 to set up ads and generate invocation code.
PHP Invocation
The first tip is how to use php invocation code. Using javascript is possible, but not all browsers support javascript and, in my experience, using php is faster.
The php invocation code phpadsnew generates will look something like this...
Place it in your PHPINCLUDE_START template, but omit the final echo statement and the <?php ?> tags. It will look like this...
PHP Code:
if (@include(getenv('DOCUMENT_ROOT').'/phpads/phpadsnew.inc.php')) {
if (!isset($phpAds_context)) $phpAds_context = array();
$phpAds_raw = view_raw ('zone:2', 0, '', '', '0', $phpAds_context);
}
Now, to place the add, put the variable $phpAds_raw[html] in any template that you want that ad to appear (usually your header). Remember to omit the '' marks when placing the variable in a normal template - therefore $phpAds_raw['html'] becomes $phpAds_raw[html]
If you have multiple zones, you can string these together. On EN World we have a zone that only appears on our vbadvanced news page. On those pages we call the view_raw function an additional time for the extra zone (view_raw is the function that actually calls up the ad - the rest of the code initializes phpadsnew). Here's our code, as an example of a 2 zone system.
Running Maintenance.php from the scheduled task manager
Ads new's maintenance.php file needs to run on a regular basis for it to perform correctly. You can invoke it from your scheduled task manager if you wish. If you do, I'd advise applying the following mod to the code of the maintenance.php file.
Open it and go to the ending ?> mark. Right about it add this.
PHP Code:
log_cron_action('PHP Ads New Maintenance Complete', $nextitem);
And you're done. The file can now log it's cron action with vbulletin's cron manager. Note that if you make this change you will be unable to call the maintenance.php file without vbulletin since it will trigger a fatal error (call to undefined function). Also, there's a glitch in phpadsnew - when vbulletin invokes maintenance.php it somehow forgets that it was ever invoked. The log files both in vbulletin and in phpadsnew itself speak differently, but phpadsnew continues to echo a message saying the maintenance.php script hasn't been ran which can be ignored.
Is there a manual to do this in 3.5 with the hook system? The phpinclude_start is not in the vbulletin 3.5 version, but I cant get it to work with hook > global_start.
The table 'ls1ads.forum' does not exist and the phpAdsNew database is called ls1ads and the forum DB is called ls1 so it appears the new version of phpAdsNew is screwing with something where vBulletin is concerned.
Database error in vBulletin 3.5.0 Release Candidate 3:
Invalid SQL:
SELECT
user.username, (user.options & 512) AS invisible, user.usergroupid,
session.userid, session.inforum, session.lastactivity,
IF(displaygroupid=0, user.usergroupid, displaygroupid) AS displaygroupid
FROM session AS session
LEFT JOIN user AS user ON(user.userid = session.userid)
WHERE session.lastactivity > 1126235465
ORDER BY username ASC;
MySQL Error : Table 'florida_phpads.session' doesn't exist
Error Number : 1146
Date : Thursday, September 8th 2005 @ 11:26:05 PM
Script : http://www.floridastreetscene.com/testforums/index.php?
Referrer : http://www.floridastreetscene.com/testforums/admincp/index.php?do=head
IP Address : 68.223.209.100
Username : zeno
Classname : vb_database
That used to happen to me too. The fix is found goin to Settings > Main Settings > In Database optimisations, check the option that reads: "Use database compatibility mode"
That used to happen to me too. The fix is found goin to Settings > Main Settings > In Database optimisations, check the option that reads: "Use database compatibility mode"
So how do I run 2 zones on one page? I have set up the 2nd zone and put the invocation code in phpincludes_start...but what tag do I put on the page (footer)? Right now I have the same tag on both places and so the zone 1 ad shows in both places.
Right now I have the '$phpAds_raw[html]' in my navbar template. How come when vbulletin message comes up (you just logged out, or you dont have permission to this page) the banner disappears? What do I edit so that it's visible there too?
Warning: Cannot modify header information - headers already sent by (output started at /home/www/>>>>>>/www/includes/adminfunctions.php:222) in /home/www/>>>>>>/www/adserver/libraries/lib-cache.inc.php on line 16
Warning: Cannot modify header information - headers already sent by (output started at /home/www/>>>>>>/www/includes/adminfunctions.php:222) in /home/www/>>>>>>/www/adserver/libraries/lib-cache.inc.php on line 17
Warning: Cannot modify header information - headers already sent by (output started at /home/www/>>>>>>/www/includes/adminfunctions.php:222) in /home/www/>>>>>>/www/adserver/libraries/lib-cache.inc.php on line 18
Done
I am getting this errror after manual run of PhpAdsNew cron job on Vbulletin.