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
  #112  
Old 10-07-2006, 08:29 PM
smoknz28's Avatar
smoknz28 smoknz28 is offline
 
Join Date: Sep 2005
Location: SoCal
Posts: 257
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by onliner7
you prolly have the same code somewhere else too? do a search mate
Should I be searching for: echo $phpAds_raw['html'];

Been looking in my forumhome template and only found one instance with phpAds in it and that was the code that I just added.

Also, if I'd like to add more than one banner, would I just add the code from phpAdsNew into the plugin code just as I did to make the initial one appear?
Reply With Quote
  #113  
Old 10-07-2006, 09:56 PM
onliner7 onliner7 is offline
 
Join Date: May 2006
Location: greece
Posts: 23
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

if you want to add a new banner you will probably have to make a new variable

for example.. a new plugin with the code

PHP Code:

ob_start
();

if (@include(
getenv('DOCUMENT_ROOT').'/ads/phpadsnew.inc.php')) {
        if (!isset(
$phpAds_context)) $phpAds_context = array();
        
$aNewVariable view_raw (''0'_blank''''0'$phpAds_context);
    }

ob_end_clean(); 
notice the new variable name (it was phpAds_raw but now i made a new one called aNewVariable

then anywhere in your template

{$aNewVariable['html']}


i havent tested this but i think it should work OK

Jason
Reply With Quote
  #114  
Old 10-12-2006, 06:16 AM
onliner7 onliner7 is offline
 
Join Date: May 2006
Location: greece
Posts: 23
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

In addition to the code i've posted here

https://vborg.vbsupport.ru/showpost....&postcount=106

I would like to add something else for the peeps that want it to work with vbAdvanced

go to Admin CP -> vBA CMPS -> Default Settings -> Portal Output Global Variables

and add

PHP Code:
phpAds_raw 
to that textbox..

This will work with the latest phpAdsNew 2.0.8 and vBulletin 3.6.x

if you have more than one ads then you need to externalize (ie write all variables into this textbox without the $ in front) all variables you have in your hooks.. but the above will work with one ad just fine

as always check www.pbzone.net to see it working

A big thanks to this community it keeps me learning new things all the time

p.s. if anyone has benefited from this or has problems please email me
Reply With Quote
  #115  
Old 11-05-2006, 04:14 AM
smoknz28's Avatar
smoknz28 smoknz28 is offline
 
Join Date: Sep 2005
Location: SoCal
Posts: 257
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Will this work for multiple banners?
Reply With Quote
  #116  
Old 11-06-2006, 12:52 PM
myplacidcasual myplacidcasual is offline
 
Join Date: Sep 2006
Posts: 44
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

having some difficulty here. if I were to put the code:

{$phpAds_raw['html']}

into my header, would i place it inside a <td> or outside of it.

OH MY GOD!

So yeah I just took the javascript invocation code and plugged it into the bottom of the header. Everythign is fine now.

God da$#$n't that was a lotta time wasted.

Am I the only one who feels like an idiot at least 90 percent of the work day thanks to vbulletin?
Reply With Quote
  #117  
Old 11-07-2006, 12:29 PM
smoknz28's Avatar
smoknz28 smoknz28 is offline
 
Join Date: Sep 2005
Location: SoCal
Posts: 257
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by myplacidcasual
OH MY GOD!

So yeah I just took the javascript invocation code and plugged it into the bottom of the header. Everythign is fine now.

God da$#$n't that was a lotta time wasted.
Exactly....did you read my other posts that talked about doing this?

Man, I had no idea that it was that simple until I started thinking about what I did with ubb Threads. After trying about 3 different hacks.... I had just tested out the Java invocation code....and whalla.

What I'd like to do however, is insert a table where I can put the java code to the right of my banner. Here's what my header currently looks like: www.f-bodyhideout.com/forums

If someone knows how to do it....please PM me or post up here.

Thanks...

Glad you're up and running myplacidcasual.
Reply With Quote
  #118  
Old 11-10-2006, 04:41 AM
imported_infitech's Avatar
imported_infitech imported_infitech is offline
 
Join Date: Apr 2004
Location: Queens, NY
Posts: 247
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

i dont have PHPINCLUDE_START

Quote:
Originally Posted by onliner7
In addition to the code i've posted here

https://vborg.vbsupport.ru/showpost....&postcount=106

I would like to add something else for the peeps that want it to work with vbAdvanced

go to Admin CP -> vBA CMPS -> Default Settings -> Portal Output Global Variables

and add

PHP Code:
phpAds_raw 
to that textbox..

This will work with the latest phpAdsNew 2.0.8 and vBulletin 3.6.x

if you have more than one ads then you need to externalize (ie write all variables into this textbox without the $ in front) all variables you have in your hooks.. but the above will work with one ad just fine

as always check www.pbzone.net to see it working

A big thanks to this community it keeps me learning new things all the time

p.s. if anyone has benefited from this or has problems please email me
ur the man!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Reply With Quote
  #119  
Old 11-10-2006, 03:09 PM
voteforbird's Avatar
voteforbird voteforbird is offline
 
Join Date: Jul 2006
Posts: 121
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I tried the instructions above, but it isn't working with my 3.6.2. When I add the plugin, I get a MySQL error:
Quote:
MySQL Error : Table 'volconvo_phpadsnew.blogs' doesn't exist
Table blogs is in my vBulletin table, but it's trying to fetch it from my ads table.
Reply With Quote
  #120  
Old 11-12-2006, 08:00 AM
imported_infitech's Avatar
imported_infitech imported_infitech is offline
 
Join Date: Apr 2004
Location: Queens, NY
Posts: 247
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

this has helped me a great deal - thank u so much.....
****installs****
Reply With Quote
  #121  
Old 02-26-2007, 06:46 PM
burntire burntire is offline
 
Join Date: Jun 2006
Posts: 141
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Has anyone got this working without using the Java invocation code?

I am trying to get this to work with the local invocation code with 3.6.4.
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 08:54 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.04845 seconds
  • Memory Usage 2,328KB
  • 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
  • (7)bbcode_php
  • (4)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
  • (3)pagenav_pagelink
  • (1)pagenav_pagelinkrel
  • (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