Go Back   vb.org Archive > vBulletin Article Depository > Read An Article > vBulletin 3 Articles

Reply
 
Thread Tools
Using PHPadsnew 2 with Vbulletin 3.
Michael Morris's Avatar
Michael Morris
Join Date: Nov 2003
Posts: 774

Employee of Digital Media Graphix of Knoxville TN, currently developing a new framework / CMS

Knoxville TN
Show Printable Version Email this Page Subscription
Michael Morris Michael Morris is offline 01-30-2005, 10:00 PM

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...

PHP Code:
<?php
    
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);
        echo 
$phpAds_raw['html'];
    }
?>
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.

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);
        if (
defined('VBA_PORTAL'))
        {
            
$phpAds_context2 = array();
            
$phpAds_raw2 view_raw ('zone:3'0'''''0'$phpAds_context2);
        }
    }

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.

Any other tips/comments/questions welcomed.

PHP Ads New 2 is at http://www.phpadsnew
Reply With Quote
  #82  
Old 10-02-2005, 10:48 PM
Chris 96 WS6 Chris 96 WS6 is offline
 
Join Date: Jul 2005
Posts: 49
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by mikexxx
Just put $phpAds_raw2[html] in any template
You're going to have to dumb it down for me more. Nowhere in the invocation code for zone 2 does "$phpAds_raw2[html]" show up, so the call for zone 1 and zone 2 are the same. When I put $phpAds_raw2[html] in the template, that call doesn't seem to reference anything in PAN.

I'm lost.

How does this site: www.gearchatter.com, generate the zone on the left to diplay all his ads?
Reply With Quote
  #83  
Old 10-06-2005, 11:42 PM
Big Kahuna's Avatar
Big Kahuna Big Kahuna is offline
 
Join Date: Feb 2002
Location: SE Texas
Posts: 182
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I know whenever you help people with something like this -- you open a can of worms that keeps you busy putting out people's fires.

I followed your distructions and added 6 banners (six different invocation codes) to my 30+ styles at www.moparstyle.com -- and everything works great.

99.44% of the time when I use one of the hacks here -- everything works fine. When it doesn't -- I generally find a typo on my part when I reread.

This is long way of saying all is well -- and I appreciate your help. Much faster than having the server running all of that Java code.
Reply With Quote
  #84  
Old 10-07-2005, 02:36 AM
jsharper jsharper is offline
 
Join Date: Jun 2005
Location: Gilbert, AZ, US
Posts: 21
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Chris 96 WS6
You're going to have to dumb it down for me more. Nowhere in the invocation code for zone 2 does "$phpAds_raw2[html]" show up, so the call for zone 1 and zone 2 are the same. When I put $phpAds_raw2[html] in the template, that call doesn't seem to reference anything in PAN.

I'm lost.
The invocation code given by phpadsnew is just a template or an example of how to display that particular zone. When you have more than one banner on a page, the invocation code for at least one of them will have to be modified so that you don't have conflicting variable names. If $phpAds_raw[html] is set to contain the html for one zone, then you aren't going to be able to reuse that same variable to store the html for the next zone -- you'll have to change that variable to something else both in the invocation code and where you use it. Some people choose to use $phpAds_raw2[html] for the 2nd zone.
Reply With Quote
  #85  
Old 10-07-2005, 04:09 AM
Pulsorock Pulsorock is offline
 
Join Date: Oct 2001
Posts: 111
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I'm trying to place more than one ad (different zones) on my templates. On the header template I placed the first one, then on the postbit template I want to place another. On other template, I want to place the last one. But I'm not able to display them. Just the first one displays. Here is the code I placed on the phpinclude_start template:

Code:
ob_start();

if (@include(getenv('DOCUMENT_ROOT').'/maxserver/phpadsnew.inc.php'))
{
	if (!isset($phpAds_context))
	{
  //LeaderBoard Banner
  $phpAds_context = array();
  $phpAds_raw = view_local ('', 5, 0, 0, '_blank', '', '0', $phpAds_context);

  //Medium Rectangle
  $phpAds_context2 = array();
  $phpAds_raw2 = view_local ('', 21, 0, 0, '_blank', '', '0', $phpAds_context2);
  
  //Wide Skyscraper
  $phpAds_context3 = array();
  $phpAds_raw3 = view_local ('', 37, 0, 0, '_blank', '', '0', $phpAds_context3);
	}
}

ob_end_clean();
On the header I place the code: $phpAds_raw[html]. And it shows the leaderboard banner. Then on the postbit template I place the code: $phpAds_raw2[html]. But it does not appear anything. I also tried placing on the postbit template: $phpAds_raw[html], but it does not show anything.

Note: I'm using MMM 0.1.x
Reply With Quote
  #86  
Old 10-11-2005, 02:51 AM
SashaCPF SashaCPF is offline
 
Join Date: Aug 2005
Posts: 13
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I have one spot in my header that I want to have 43 banners rotate in. I want them to rotate with each page change or refresh. I am using direct selection. I can get one banner to display... I can get two banners to display next to each other at the same time. How do I get them to rotate... one at a time? Code?
Reply With Quote
  #87  
Old 10-30-2005, 11:16 PM
acorndomains.co acorndomains.co is offline
 
Join Date: Mar 2005
Posts: 27
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I cant get this to work even following the instructions on the first page of this thread.

Soes anyone have simple instructions to follow to get this running on VB 3.5.0??

Many thanks
Reply With Quote
  #88  
Old 11-08-2005, 06:20 PM
NxTek NxTek is offline
 
Join Date: Jun 2003
Posts: 105
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Does this work with vB 3.5.1?
Reply With Quote
  #89  
Old 11-25-2005, 08:51 PM
MarkCSCS MarkCSCS is offline
 
Join Date: Feb 2005
Posts: 1
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hey Guys and Gals, can you guys help me out.

I'm installing PHPadsnew and I appear to have everything working on my server and html site. I'm trying to finish the install/integration into my Vb 3.51 forums.

The instructions say to modify the PHPINCLUDE_start template. For the life of me, I cannot find this template. I've looked through the templates and either I'm blind or its not there. Is this a template in vB 3.51? If so, where is it if, because apparently I'm blind, and running search in templates is not showing it to me.

If it's not a template in 3.51; then what should I modify to get this hack to work?

Thanks!
Reply With Quote
  #90  
Old 11-26-2005, 04:14 AM
jsharper jsharper is offline
 
Join Date: Jun 2005
Location: Gilbert, AZ, US
Posts: 21
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Mark,
The phpinclude_start template is gone starting with 3.5. It is replaced with the plugins system. Try adding a new plugin with a hook location of global_start and put the phpAdsNew code in there.
Reply With Quote
  #91  
Old 12-22-2005, 01:41 PM
Masiello's Avatar
Masiello Masiello is offline
 
Join Date: Jul 2005
Location: Italy
Posts: 426
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I have create a new plug-in (globalstart hook) and insert the code of the first post
in header the raw html, and just set the schedule task righ, but when I active the plug-in and try to open my page, it dont be able to connect to the database, why?

my vbulletin version is 3.5.2 and using vba index in the root dir with forum in /forum dir
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 09:34 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04870 seconds
  • Memory Usage 2,321KB
  • Queries Executed 25 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)bbcode_code
  • (4)bbcode_php
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_article
  • (1)navbar
  • (4)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (11)post_thanks_box
  • (11)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (11)post_thanks_postbit_info
  • (10)postbit
  • (11)postbit_onlinestatus
  • (11)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete