PDA

View Full Version : Embedding random ads / rotation


sparklywater
02-20-2009, 06:20 PM
I have two <scripts> for embedding ads, one for Google adsense and the other for Amazon associates. Instead of embedding the two ads separately on a single page, is it possible to randomly alternate between these two ads (which are of the same size) so that they don't have to be embedded on two different places on the page?

Dismounted
02-21-2009, 03:29 AM
You will need to create a plugin to do this:
$rand = rand();

if ($rand % 2)
{
$ad = 'SOME CODE';
}
else
{
$ad = 'SOME OTHER CODE';
}

sparklywater
02-21-2009, 04:56 AM
How do I apply that at a specific part of my template, ie. at the location where I want my ads?

vbplusme
02-21-2009, 07:16 AM
Where you place the variable $ad in your template is where it would display.