Rotating Banners and other Advertisments
For those of you who have been looking for a way to rotate your 468x60 or 336x280 advertisments here is a solution for you. You can even use animated GIF files to add some flare to your ads.
Notice: I did not write this code. I found it a long time ago somewhere and thought it might be useful here.
This code will rotate banners and their associated links everytime the screen is refreshed or you click another post, category, page or whatever. As long as ClassiPress loads a new page, your banner will change.
All you have to do is go to the Admin Dashboard --> ClassiPress --> Settings.
Once you are there, just cut and paste the following code into the "
Ad Code:" box under either the "
Header Ad (486x60)" or the "
Single Ad (336x280)". After you have pasted the code all you have to do is enable the ad and save the changes.
Code:
<script language="Javascript">
<!--
var currentdate = 0;
var core = 0;
function initArray() {
this.length = initArray.arguments.length;
for (var i = 0; i < this.length; i++) {
this[i] = initArray.arguments[i];
}
}
link = new initArray(
"http://www.yourdomain.com/your_link_1",
"http://www.yourdomain.com/your_link_2",
"http://www.yourdomain.com/your_link_3",
"http://www.yourdomain.com/your_link_4",
"http://www.yourdomain.com/your_link_4"
);
image = new initArray(
"http://www.yourdomain.com/your_image_name_1.gif",
"http://www.yourdomain.com/your_image_name_2.jpg",
"http://www.yourdomain.com/your_image_name_3.gif",
"http://www.yourdomain.com/your_image_name_4.jpg",
"http://www.yourdomain.com/your_image_name_5.jpg"
);
text = new initArray(
"Alt Text Goes Here for Banner 1",
"Alt Text Goes Here for Banner 2",
"Alt Text Goes Here for Banner 3",
"Alt Text Goes Here for Banner 4",
"Alt Text Goes Here for Banner 5"
);
var currentdate = new Date();
var core = currentdate.getSeconds() % image.length;
var ranlink = link[core];
var ranimage = image[core];
var rantext = text[core];
document.write('<a href="' +ranlink+ '"><img src="'+ranimage+'" border="1" alt="'+rantext+'"></a>');
//-->
</SCRIPT>
Configuring the code above for your ads is very simple. Just replace the links, image urls and Alt Text entries for each ad you want to display. If you want more than five ads just add additional links, image urls and alt text entries. Make sure you ad them in equal numbers. If you have five ads, you have to have five links, five image urls and five alt text entries.
If you do not ant Alt Text, make it look like the sample below.
Code:
text = new initArray(
"",
"",
"",
"",
""
);
Note that when you are editing the number of ads to be displayed the last entry in each array does not have a "," at the end.
If you have any questions, please feel free to ask and I will try to help as best I can.
Thanks,
David
Last edited by pepsi; November 10th, 2010 at 04:24 PM.