PDA

View Full Version : Miscellaneous Hacks - Show a rotating banner ad for specific user id's


davis31b
04 Jun 2008, 21:06
This is a simple ad script that will enable you to place as many ads as you want into your forums, and this script will automatically rotate your banners for you so you won't clutter up the forums by having banners stacked on top of each other or side by side.

This will also make sure to only display the person viewing the forums if they are a member of:
Usergroup 1: Unregistered / Not Logged In
Usergroup 2: Registered Users

Also a small text link below the banner gives the user an incentive to click on the small link to become a paying member to disable the ads on your forums.

I'm also aware that VB has ad hooks installed, but many of us are using a custom style, so it makes it a little easier sometime to add scripts like this. I recommend using a banner ad (468 x 60) as pictured. You can also increase or decrease the number of banners it displays by changing: var how_many_ads = 3; & copying and pasting a new ad section within the javascript.

Find in header template: (usually at very bottom)

$ad_location[ad_header_end]

and after add:


<!-- Begin Ad -->
<if condition="is_member_of($bbuserinfo, 1,2)">
<table class="tborder" cellpadding="6" cellspacing="1" border="0" width="100%" align="center">
<tr>
<td class="alt1" width="74%">
<script LANGUAGE="JavaScript">
var how_many_ads = 3;
var now = new Date()
var sec = now.getSeconds()
var ad = sec % how_many_ads;
ad +=1;
if (ad==1) {
url="sendmessage.php";
alt="Banner Ad";
banner="/content/images/ad.png";
width="468";
height="60";
}
if (ad==2) {
url="http://tinyurl.com/5z999z";
alt="Targeted Website Traffic";
banner="http://www.buyawebsitetraffic.com/aff/banners/468x60_02.gif";
width="468";
height="60";
}
if (ad==3) {
url="http://www.somethingsexy.com";
alt="Somethingsexy.com";
banner="/content/images/somethingsexy.gif";
width="460";
height="60";
}
document.write('<center>');
document.write('<a href=\"' + url + '\" target=\"_top\">');
document.write('<img src=\"' + banner + '\" width=')
document.write(width + ' height=' + height + ' ');
document.write('alt=\"' + alt + '\" border=0><br>');
document.write('</center>');
</script>
<center>
<a href="payment.php"><font size="1" color="red">Purchase a subscription to make the forums ad free!</font></a>
</center>
</td>
</tr>
</table>
</if>
<!-- End Ad -->


Replacements:
Text in red can be customized to better suite your forums.

*SCREEN SHOT ATTACHED*
Also please be aware that my site is [NWS].

-Enjoy!

fourat
06 Jun 2008, 17:00
thanks

is this code changing between the banners when i refresh the page ?
is this code make the pages Valid XHTML or not ?

davis31b
06 Jun 2008, 20:15
thanks

is this code changing between the banners when i refresh the page ?
is this code make the pages Valid XHTML or not ?


Yup, you only will see one banner at a time, everytime you refresh a new one will be there. You can add as many banners as you would like. As far as being a valid XHTML document, I guess to better answer that is this code works properly and am not having any issues at this time.