You are here:  » How to write file name for search query that includes a keyword + merchant


How to write file name for search query that includes a keyword + merchant

Submitted by Retro135 on Sun, 2017-02-05 08:34 in

Hi David,
You created a mod so I could include custom searches in my sidebar:
 $srchinfoFilename = "srchinfo/directory/".$srchinfoName.".html";
The file naming for a brand, merchant or keyword is straightforward (keyword.html, merchant_name.html). However, I have some searches that include a keyword and a merchant filter ( q=keyword&merchantFilter=Merchant).

Is it possible to name the .html file to include both the keyword & a merchant or brand?

Submitted by support on Mon, 2017-02-06 12:29

Hi,

Looking back at our email I see you have code something like this;

  $srchinfoName = str_replace(array(":",".","/"," "),"_",trim($q,":"));
  $srchinfoFilename = "srchinfo/".$srchinfoName.".html";

So what you could do is that if a merchant filter filter in effect, append with "_Merchant" to the base name ($srchinfoName) and similarly if a brand filter is in effect - have a go with something like;

  $srchinfoName = str_replace(array(":",".","/"," "),"_",trim($q,":"));
  if ($merchantFilter)
  {
    $srchinfoName .= "_".str_replace(" ","_",tapestry_normalise($merchantFilter));
  }
  if ($brandFilter)
  {
    $srchinfoName .= "_".str_replace(" ","_",tapestry_normalise($brandFilter));
  }
  $srchinfoFilename = "srchinfo/".$srchinfoName.".html";

And then use, for example;

srchinfo/keyword_Merchant_Name.html

Cheers,
David.
--
PriceTapestry.com

Submitted by Retro135 on Tue, 2017-02-07 06:36

Works a charm! Thank you!