You are here:  » create content for search page


create content for search page

Submitted by wilkins on Fri, 2014-07-04 08:50 in

Hi David

I am creating a site that the main focus will be on the search page. What I want to know is there any way the create original content for each search term.

ie if the search term is ipod headphones to display content at the top of the search page just for ipod headphones.

Re
regards

Brent

Submitted by support on Fri, 2014-07-04 09:33

Hello Brent,

Sure! Create a new folder on your site called "searchinfo". Inside that folder, create .html files with a file name in all lower case exactly matching the search term you wish to display that content for, including spaces, so you will have, for example,

searchinfo/ipod headphones.html
searchinfo/blue widgets.html
searchinfo/red widgets.html

Then at the top of html/searchresults.php add the following code to display the custom HTML on page 1 of matching search terms:

<?php
  
if ($page==&& !isset($parts[1]))
  {
    
$searchinfoFilename "searchinfo/".strtolower($q).".html";
    if (
file_exists($searchinfoFilename))
    {
      require(
$searchinfoFilename);
    }
  }
?>

If you want the content displayed on all pages (beware of possible duplicate content issues) then replace the condition with just:

  if (!isset($parts[1]))

Hope this helps!

Cheers,
David.
--
PriceTapestry.com