You are here:  » content on search result pages

Support Forum



content on search result pages

Submitted by babrees on Thu, 2009-02-05 07:03 in

Is it possible to have specific content on the search pages? So when I get a search result on, say, jumpers it will insert the file I have called jumpers from, say, the "content" folder?

The same for categories.

Submitted by support on Thu, 2009-02-05 11:15

Hi Jill,

Sure. If you make a folder on your site using the name suggested: "content", you could add the following code to search.php (towards the end, in amongst the require("html/...") as required:

$contentFilename = "content/".strtolower($q);
if (file_exists($contentFilename))
{
  require($contentFilename);
}

If it makes it easier with your editor to have the files named .html or .txt, just add the extension to the $configFilename variable, for example:

$contentFilename = "content/".strtolower($q).".html";

...and then create files in the content folder with a name that exactly match the query (as shown in the text box on the search results page) but in lower case, for example:

content/jumpers.html
content/category:ladies clothing:.html

Cheers,
David.

Submitted by babrees on Mon, 2009-03-16 06:06

This is working great, but can I adjust it so that it only shows on the first page of the results and not pages 2,3 etc.?

---------
Jill

Submitted by support on Mon, 2009-03-16 09:28

Hi Jill,

Sure - you can wrap the entire code that you added within if($page==1), for example:

if ($page==1)
{
  $contentFilename = "content/".strtolower($q);
  if (file_exists($contentFilename))
  {
    require($contentFilename);
  }
}

Cheers,
David.

Submitted by babrees on Sat, 2009-03-21 06:58

Going even one more further with this...

With the above, the search results page no longer shows the order choice.

Is it possible to include(showing 1 to 20 of 10572)
Order by Relevance, Product Rating | Price Low to High, High to Low
??

---------
Jill

Submitted by support on Sat, 2009-03-21 09:42

Hi Jill,

I'm not sure why it would be hiding the order choice - could you email me your modified search.php and i'll take a look!

Cheers,
David.