Hi I would like to have the main top banner to display a random banner out of a selection so it changes each time you go onto the site.. How can I go about this
Thanks shane
Printable View
Hi I would like to have the main top banner to display a random banner out of a selection so it changes each time you go onto the site.. How can I go about this
Thanks shane
Install OpenX or another ad serving software
Download OpenX Source | OpenX
I have a simple php rotate script if you want it : Works best with banners of the same size :
Step one: create a folder (in this case i used rotate1) so http://yoursite.com/rotate1/
Step two: create file called rotate.php and enter this text ::
Step 3: Make html files each file with the banner code you want and name them 1.html .html excCode:<?php/*
By Matt Mullenweg > http://photomatt.net
Inspired by Dan Benjamin > http://hiveware.com/imagerotator.php
Latest version always at:
http://photomatt.net/scripts/randomimage
*/// Make this the relative path to the images, like "../img" or "random/images/".
// If the images are in the same directory, leave it blank.
$folder = '';
// Space seperated list of extensions, you probably won't have to change this.
$exts = 'html';
$files = array(); $i = -1; // Initialize some variables
if ('' == $folder) $folder = './';
$handle = opendir($folder);
$exts = explode(' ', $exts);
while (false !== ($file = readdir($handle))) {
foreach($exts as $ext) { // for each extension check the extension
if (preg_match('/\.'.$ext.'$/i', $file, $test)) { // faster than ereg, case insensitive
$files[] = $file; // it's good
++$i;
}
}
}
closedir($handle); // We're not using it anymore
mt_srand((double)microtime()*1000000); // seed for PHP < 4.2
$rand = mt_rand(0, $i); // $i was incremented as we went along
header('Location: '.$folder.$files[$rand]); // Voila!
?>
They must be in the same folder as the php script you created... and works best with numbers only!!
Step 4: Add the iframe code to where you want the banner ::
Make sure you change the iframe size! You need it slightly bigger than the banner.Code:<center><iframe src="http://Yoursite.com/rotate1/rotate.php" width="500" height="100" frameBorder="0"><p>Place a non iframe banner (without flash or java here so a banner will always show if the users browser does not support these</p>
</iframe>