Is there a way to use a code to place text links, banners, or ad space on a certain number of pages within site, excluding the sidebar or within sidebar on certain number of pages. For sites that are not doing well, can I place some type of code to sell ad spce, text links or banners on a certain number of pages, categories, brands, or product pages? Lets say I sell text links on 2 pages, 3 pages, homepage, brand pages or etc. Is there a way I can ad a snippet of php code to do this?
Thank you,
Roy S.
Hello Roy,
Sure - the $_SERVER["PHP_SELF"] variable can be used to programmatically include PHP code based on which .php file (e.g. merchants.php, search.php) is being used to generate, and then further still you can base included code on variables in use within that page, such as $q (the query) for search.php and products.php. The basic structure, which would go within your sidebar code, might look something like this:
<?php
switch($_SERVER["PHP_SELF"])
{
case "search.php":
?>
<!-- HTML snippet to show on search pages here -->
<?php
break;
case "products.php":
?>
<!-- HTML snippet to show on product pages here -->
<?php
break;
}
?>
Then to extend that to only show snippets for, say the product "Blue Widget", use:
<?php
switch($_SERVER["PHP_SELF"])
{
case "search.php":
?>
<!-- HTML snippet to show on search pages here -->
<?php
break;
case "products.php":
if ($q == "Blue Widget")
{
?>
<!-- HTML snippet to show on product pages here -->
<?php
}
break;
}
?>
Hope this helps,
Cheers,
David.