Submitted by ICH on Mon, 2010-09-27 01:28 in Price Tapestry
is there any easy solution in order not to show certain banners (ie adsense)on products from certain categories, even better when those categories products are shown on a search made by the user?
Sure! At the point at which you have added your AdSense codes (presumably in your header or footer files), you can simply surround it by a PHP if() condition to determine exactly what pages you want the banner code displayed on.
Let's say you've added AdSense code within html/header.php. Firstly, to make sure that the code only appears on the products page, use:
<?php if (strpos($_SERVER["SCRIPT_FILENAME"],"products.php")!==FALSE): ?>
<!-- banner ad HTML code here --> <?php endif; ?>
Taking it a step further, to display only on the products page, and only for products from a list of categories; use something like this:
<?php if (strpos($_SERVER["SCRIPT_FILENAME"],"products.php")!==FALSE): ?>
<?php
$bannerCategories = array("Category 1","Category 2","Category 3");
if (in_array($product["products"][0]["category"],$bannerCategories)):
?>
<!-- banner ad HTML code here --> <?php endif; ?> <?php endif; ?>
Hi,
Sure! At the point at which you have added your AdSense codes (presumably in your header or footer files), you can simply surround it by a PHP if() condition to determine exactly what pages you want the banner code displayed on.
Let's say you've added AdSense code within html/header.php. Firstly, to make sure that the code only appears on the products page, use:
<?php if (strpos($_SERVER["SCRIPT_FILENAME"],"products.php")!==FALSE): ?>
<!-- banner ad HTML code here -->
<?php endif; ?>
Taking it a step further, to display only on the products page, and only for products from a list of categories; use something like this:
<?php if (strpos($_SERVER["SCRIPT_FILENAME"],"products.php")!==FALSE): ?>
<?php
$bannerCategories = array("Category 1","Category 2","Category 3");
if (in_array($product["products"][0]["category"],$bannerCategories)):
?>
<!-- banner ad HTML code here -->
<?php endif; ?>
<?php endif; ?>
Hope this helps!
Cheers,
David.
--
PriceTapestry.com