Saturday 1 December 2007

Ads within your category columns

From This:

To This:


Notice how the ad is in placed in the middle column of the category display. How I did this was to edit the homecatbox.php file which you will find in your theme 21 folder.

Open up homecatbox.php and locate the line $a = 0; immediately after add the line $ads = 0;

Now find:

echo "<div align='right'><a href='".get_category_link("name=".$category['name'])."'>More ".$category['name']." ".$category['type']." »</a></div>";

echo "
</div>
</div>
</td>";

Immediately after add:

if ($ads == 1) { // Set to the number of the position prior to the one you wish the ad to be placed e.g. for position 2 as in my pics I entered the number 1.
echo "<td width='".$width."%' valign='middle'>";
echo "
<div>

<center>";
echo 'YOUR AD CODE HERE';
echo "
</center>

</div>

</td>";
$a++;
$ads++;
}

Now this should work however I have done other modifications to this file and have had to take this out but I am confident it should still do the trick. As usual though, any problems just get in touch with me.

Also where you ad the code you could use a showad tag so that you are able to change the ad from the admin panel but I have started to remove this feature and hardwire the ads therefore I haven't done that.