At the top of my forum, can I install a 'rotating' banner that switches to a different sponsor/banner every 'x' seconds or is different everytime the page is loaded?? It should just be HTML, right? anyone know the code? thanks in advance everyone!
Can I add a 'rotating' sponsor banner to my Forum?
Collapse
X
-
Tags: None
-
Re: Can I add a 'rotating' sponsor banner to my Forum?
I use this simple Java script.. :
<script LANGUAGE="JavaScript">
var NumberOfAds =1;
var now = new Date()
var sec = now.getSeconds()
var AdNumber = sec % NumberOfAds;
AdNumber +=1;
if (AdNumber==1)
{
url="target.url.here";
Graphic="image.url.here";
width = "494"
height = "76"
}
document.write('<center>');
document.write('<a href=\"' + url + '\">');
document.write('<img src=\"' + Graphic + '\" width=')
document.write(width + ' height=' + height + ' ');
document.write('border=0><br>');
document.write('</a>');
document.write('</center>');
</script>
-
PHP Code:<?php
$folder = "http://www.mysite.com/images"; //your images folder no trailing slash
$images = array("1" => "image1.gif", "2" => "image2.gif"); //all your images seperated by a comma.
$link = array("1" => "www.asdf.com", "2" => "www.yahoo.com"); //where you want to send them
$ads = "2"; //the number of images you have
$num = rand(1, $ads);
echo "<a href=\"http://$link[$num]\"><img src=\"$folder\$images[$num]\"><a>";
?>
<? include('rotator.php'); ?>
change the images to your images
[edit] Tested the code and fixed it . it works [/edit]Last edited by Goldfinger; Thu 20 Dec '01, 7:42pm.Comment
-
Thanks Goldfinger! I've been wanting to do this on my site for a while. PHP is amazing ...
nik** just call me nik **Comment
-
-------------------------------------------------------------------------------
just save this as rotator.php in notepad , upload and call it where you want it to be..
<? include('rotator.php'); ?>
change the images to your images
---------------------------------------------------------------------------------
Hi ,
I am trying to install this and having a few problems... sorry Im a novice!! Saved php file as rotator.php in the forums directory and I am attempting to call it in the header template (above the buttons)
Is the <?include('rotator.php'); ?> all you have to enter or do I need to specify a directory?
my ad banner directory is http://www.esawdust.com/forums/ads
and the rotator.php is saved within the forums directory with the rest of the php files.
I made 2 default test banners and saved them to my ads directory- place the include code in the header above the usercp button code but I am not getting anything.
I really appreciate the help!
Happy Holidays
GregComment
-
try putting in the full path to in the include not the url the full path from the server. Also make sure you change the image directory to your images folder (url this time).
<? include('/home/username/whatever/rotator.php'); ?>Comment
-
Hi Goldfinger,
Thanks for your reply. I tried your suggestion with no luck. Here is how I inserted it into the header template. Maybe you or someone can see if something is wrong.
<!-- logo and buttons -->
<center>
<table border="0" width="{tablewidth}" cellpadding="0" cellspacing="0">
<tr>
<td valign="top" align="left" background="{imagesfolder}/menu_background.gif"><a
href="http://www.esawdust.com?s=$session[sessionhash]"><img src="{titleimage}" border="0" alt="$bbtitle"></a></td>
<td valign="bottom" align="right" nowrap background="{imagesfolder}/menu_background.gif">
<td valign="top" align="right">
<? include('rotator.php');?>
<!-- toplinks -->
<a href="usercp.php?s=$session[sessionhash]"><img src="{imagesfolder}/top_profile.gif" alt="Here you can view your subscribed threads, work with private messages and edit your profile and preferences" border="0"></a>
Im kinda at a loss here... not sure what is wrong. Here is my modified Rotator.php file. Both banners are in the images directory listed below.
<?php
<?php
$folder = "http://www.esawdust.com/forums/images"; //your images folder no trailing slash
$images = array("1" => "readysealbanner.jpg", "2" => "esawdust.jpg"); //all your images seperated by a comma.
$link = array("1" => "www.readyseal.com", "2" => "www.esawdust.com"); //where you want to send them
$ads = "2"; //the number of images you have
$num = rand(1, $ads);
echo "<a href=\"http://$link[$num]\"><img src=\"$folder\$images[$num]\"><a>";
?>
Thanks again!
GregComment
-
-
-
Downloaded the file to ovewrite my existing... changed my images directory to the proper and the image names. Still no luck. Can I possibly see some code where it is implemented and working? If I could at least get it come up on the screen I could work on the placement.
Thanks
GregComment
-
i dont know what isnt working for you. I tested this on my server and it works wonderfully. What are your server specs?Comment
-
I had to modify their code just a little to get it to work on my site. The problem I was having was the images not showing up. I had to change the \ between $folders and $images in the next to the last line to a /
I also added a couple things to get rid of the border around the ad and a _new on the link to make it open in a new window!
<?php
$folder = "http://www.stlracing.com/banner"; //your images folder no trailing slash
$images = array("1" => "adhere.gif", "2" => "web-hosting.gif");
$link = array("1" => "www.stlracing.com/ad.php", "2" => "www.stlracing.com/webhost-rates.php"); //where you want to send them
$ads = "2"; //the number of images you have
$num = rand(1, $ads);
echo "<a href=\"http://$link[$num]\" target=\"_new\"><img src=\"$folder/$images[$num]\" border=\"0\"></a>";
?>
In phpparsedcode portion ad this:
$myad = implode('', file("http://www.domain.com/rotator.php"));
and in header section ad
$myadLast edited by jdearing; Fri 21 Dec '01, 5:42pm.Comment
-
jdearing.
I get everything you said in the first part...but what do you mean by
"In phpparsedcode portion ad this:
$myad = implode('', file("http://www.domain.com/rotator.php"));
and in header section ad
$myad " ?
What is phpparsedcode? Sorry Im a newbie and I am having the same problems as esawdust. Do I add the first portion in the page Im calling the php with? or do I add that code in the rotator.php file? And where in the page do I add that?
ThanksComment
-
Originally posted by Visionrayjdearing.
I get everything you said in the first part...but what do you mean by
"In phpparsedcode portion ad this:
$myad = implode('', file("http://www.domain.com/rotator.php"));
and in header section ad
$myad " ?
What is phpparsedcode? Sorry Im a newbie and I am having the same problems as esawdust. Do I add the first portion in the page Im calling the php with? or do I add that code in the rotator.php file? And where in the page do I add that?
ThanksComment
Related Topics
Collapse
-
by sytyregistryFirst off, you'll need to modify the image sizing to fit some styles, but I have great results with 500x75 on default,which is a very favorable banner size for ads/announcements/etc... Secondly, I encourage...1 Photo
-
Channel: vBulletin 5 Tutorials
-
Comment