You are here:  » search filters


search filters

Submitted by rich84ts on Sun, 2012-02-05 09:52 in

Hi David,

Long time mailer first time poster.

I have looked around the forums and can see mentions of editing and extending the search filters but I can not find out how add more.

I would like to add additional filters corresponding to the new fields within SQL:

monthly price (min max)
Network (drop down)
Minutes (min - max)
Texts (min - max)
Contract Length (drop down)
Manufacturer (drop down)
Model (drop down)
Gift (drop down)

I ran into this problem trying to alter index.php to change the "search and browse by" from brand, merchant, category) to merchant, manufacturer, network...For example I have created copies of merchant.php & renamed one to network, altered the code but got no results, upon looking into it I believe it is because the filters are not in search.php - I have had a look in search.php but to be honest it blew my mind, please can you help?

Submitted by support on Sun, 2012-02-05 10:09

Hello Rich,

Rather than filters [at this stage anyway] all that would be missing is search: operators for your new fields. To add these, look for the following code beginning at line 77 in search.php:

      case "brand":
        $fields = array("merchant","category","brand");

...and replace with:

      case "brand":
      case "network":
        $fields = array("merchant","category","brand","network");

In addition, the rewrite rules in .htaccess would need to be added

RewriteRule ^network/$ networks.php
RewriteRule ^network/(.*)/$ search.php?q=network:$1:&rewrite=1&%{QUERY_STRING} [L]
RewriteRule ^network/(.*)/(.*).html$ search.php?q=network:$1:&page=$2&rewrite=1&%{QUERY_STRING} [L]

The above can be replicated for any additional field that you wish to add index searches for (as opposed to filters).

If you haven't done so already; it's probably best to install the sidebar filters mod first before implementing the above.

Once that is in place it's just a case of duplicating the min/max Price filters for each new field you want to filter based on min/max; and one of the normal filters for any additional field you want to filter by drop-down.

It should make more sense once running the sidebar filters mod as all the code is in place (it's just a case of copy / paste / rename exactly as you would have created networks.php based on merchants.php) but if you're not sure email me your modified search.php and html/seachresults.php with the main index searches working and I'll paste in the necessary duplicate code....

Cheers,
David.
--
PriceTapestry.com

Submitted by rich84ts on Sun, 2012-02-05 11:28

Thanks David,

I have managed to get in additional fields into searchresults.php and it's really taking shape!

when changing the search filters it doesn't change the results, is this something to do with search filters that i need to set up?

Submitted by support on Sun, 2012-02-05 11:34

Hi Rich,

Changes alone in html/searchresults.php won't take effect until the equivalent filter handling code in search.php has been added.

For the drop-downs, if you edit search.php and search for all instances of merchantFilter (which doesn't exist in the original search.php) and duplicate each section for, for example; networkFilter, that should be all it is...

Cheers,
David.
--
PriceTapestry.com