Showing posts with label Ads. Show all posts
Showing posts with label Ads. Show all posts

Wednesday, June 25, 2008

Nuffnang vs Advertlets at random

This tutorial will show on how to make Nuffnang and Advertlets ads to display at random (not at the same time on each page).

First you need to put this code in the header.php file.
global $x;
$x = rand(1,2);
This code will generate a random number of 1 and 2, and then substitutes it to the global variable x.

Next, insert the nuffnang and advertlets inside the code below.
if ($GLOBALS['x'] == 1) { ?>
<!--nuffnang--> <?php } else {?>
<!--advertlets--> <?php } ?>
Now, just copy the code and paste it into the template, as many as desired.

The code will show one or more nuffnang or advertlets ads at random with a chances of 50%.

Saturday, June 14, 2008

Create a Rotating Ads

If you run more than one ads, but lack of space to put the ads, you can actually rotate the ads.

The code below will create a random number from 1 to 10. Since I want both ads to be shown with a probability of 50%, I put the condition if (x > 5). However, you can change this number.

<?php $x = rand(1,10); ?>
<?php if ($x > 5) { ?>

<!--your first ad code-->

<?php } else {?>

<!--your second ad code-->

<?php } ?>
You can read more about PHP rand() function here.