View Full Version: The switching of banners

Zoids Evolution Forums > Computers and Technology > The switching of banners



Title: The switching of banners


Fury OD - June 18, 2006 09:21 PM (GMT)
Do any body know, how we can switch the banners posted above the Bord, automatically?...We, at the liger forum is a bit stuck on that, at the moment...Any advice..??

ShadowDragon062 - June 18, 2006 09:30 PM (GMT)
I think you have to link the webpage name... for example the banner on top links to the main ZE Forum page, and I think it's link to multiple banners, so that it changes each time. Not sure though..

Fury OD - June 18, 2006 10:39 PM (GMT)
Alright I'll try it..KK?..

ZeRoRaVeN - June 18, 2006 10:40 PM (GMT)
You both are obviously a tad computer illeterate but that's alright. :rolleyes:

The board on ZE uses javascript to provide random rotation, one thing I noticed is while it's not true for ZE, some sites have the banners on the same domain/url in the beginning so it would make sense to make a single variable in front, and then put that in the document.write part and put the rest of the banners in an array.

RM-METRO.NET before I switched it over to php, did something similar, then since everything was in addition to being in the same directory, file names were incrementing, I got rid of the array completely and instead did the random number for the file name itself instead.

Lastly, you could use PHP to do it instead, this is if you're going to do this on a php page, otherwise you could just link to a php page that outputs it-with the appropiate image headers being sent of course.

Fury OD - June 19, 2006 01:50 AM (GMT)
QUOTE
You both are obviously a tad computer illeterate but that's alright


You gots that right ..Well I am, anywayzz...

Alright, so I have to get that done ...I hope I know what the hell Im doing.


.COMPUERS...so much work..

HaTcH - June 19, 2006 01:57 AM (GMT)
View the source, search for the string 'HaTcH' and copy and paste the code. I commented it pretty extensively so it should be easy to implement.

In a forum setting its much easier to just use the inline Javascript code.

Knock yourselves out, my code is open source!

ZeRoRaVeN - June 19, 2006 01:59 AM (GMT)
Here's the script for ZE, while I can pratically gurantee HaTcH will say okay, I recommend you ask him before using it.

CODE
script type="text/javascript">

//Script by HaTcH 04-02-05
//To add a new banner to the list, increase TOTAL_BANNERS by 1
//and add a new line to the New Array definition

//This value is for the total number of images there are
var TOTAL_BANNERS = 13;

//This is the array containing the urls.
//You must include the entire http:// path.
var urls = new Array(
"http://i6.photobucket.com/albums/y225/zoids_evolution/Blade4.jpg",
"http://i6.photobucket.com/albums/y225/zoids_evolution/Blade2.jpg",
"http://i6.photobucket.com/albums/y225/zoids_evolution/Capitila1.jpg",
"http://i6.photobucket.com/albums/y225/zoids_evolution/DrkXFuZion1.gif",
"http://i6.photobucket.com/albums/y225/zoids_evolution/DrkXFuZion2.gif",
"http://i6.photobucket.com/albums/y225/zoids_evolution/HaTcH1.png",
"http://i6.photobucket.com/albums/y225/zoids_evolution/HaTcH2.png",
"http://i6.photobucket.com/albums/y225/zoids_evolution/K-621.gif",
"http://i6.photobucket.com/albums/y225/zoids_evolution/Mirai_LD1.jpg",
"http://i6.photobucket.com/albums/y225/zoids_evolution/Mirai_LD2.jpg",
"http://i6.photobucket.com/albums/y225/zoids_evolution/Tilly1.gif",
"http://www.creativeinsanity.net/stuff/av/zebannerpink.gif",
"http://www.bearcreekfire.com/zoids3d/downloads/zeban2.png");

//Selects a random number between 0 and the total number
//of images less 1.
var index = Math.round(Math.random()*(TOTAL_BANNERS-1));

document.write("<a href=\"http://z4.invisionfree.com/Zoids_Evolution/index.php?\" title=\"Board Home\"><img src=\""

+ urls[index] + "\" alt=\"Welcome to Zoids Evolution Forums!\" title=\"Welcome to Zoids Evolution Forums!\"></a>");

</script>


The comments are self explainatory.

Hmm, I just noticed...doesn't javascript have "count"? Couldn't that be used instead?

Count the number in the array, then send it as the total banners variable instead and subtract or do whatever with it. I can't figure out why HaTcH subtracted 1 from the total banners though..

I'm afraid I don't know javascript beyond the basic elements it shares with PHP and document.write so I can't help much further.




Hosted for free by InvisionFree