You are here:  » Advert/Adsense on search results where there are no results only

Support Forum



Advert/Adsense on search results where there are no results only

Submitted by rsachoc on Sat, 2010-02-27 17:11 in

Hi there

I'd like to include Adsense/other adverts if a user searches and there are no results. In order to centralise my Adsense code, I created a file called adsense.php in the html/folder and called that from other places where I want the ads to show - one being in the "noresults.php" file, which works fine. However if the user enters a URL (like from the search engines) they goto to a URL directly sometimes (like www.mysite.com/product/productname) and the appliance is not found, I tried to the same by adding it to products.php (in the not found section). Doing it this way I get the "warning, cannot modify header information" which I believe is because I'm calling the adsense.php file before the header.php?

Thanks

Submitted by support on Sun, 2010-02-28 10:05

Hi,

Rather than at that point in the code; instead look for the following code near the end of products.php:

  if (isset($product)) require("html/product.php");

...and REPLACE that with:

  if (isset($product))
  {
    require("html/product.php");
  }
  else
  {
    require("html/adsense.php");
  }

Cheers,
David.

Submitted by rsachoc on Sun, 2010-02-28 10:53

Thank you, that worked 100% as expected!