You are here:  » Search within a category

Support Forum



Search within a category

Submitted by Convergence on Fri, 2012-06-01 19:20 in

Greetings,

Would like to be able to search within a specific category.

Example:

Would like to be able to search for 'blue' widgets, within:

example.com/widgets/category/Large-Widgets/

Have tried:

category:Large Widgets:blue
example.com/widgets/search.php?q=category:Large+Widgets:blue

to no avail.

Noticed there is a SidebarFilters mod available in 'downloadExtras' - However, am not looking for a sidebar, just want to be able to create a query to search within a specific category.

Thanks, as always, for your superb assistance and support!

Submitted by support on Sat, 2012-06-02 12:04

Hi,

This can be done with an easy mod; by default; multiple values and merchant: category: etc. operators can be strung together as follows e.g.

merchant:Merchant 1:Merchant 2:Merchant 3:category:Category 1

To add support for the name field; first look for the following code at line 79 of search.php:

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

...and REPLACE with:

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

And then the following code at line 103:

          $where .= " ".$field." = '".database_safe($parts[$i])."' ";

..and REPLACE with:

          if ($field=="name")
          {
          $where .= " name LIKE '%".database_safe($parts[$i])."%' ";
          }
          else
          {
          $where .= " ".$field." = '".database_safe($parts[$i])."' ";
          }

...and you can then search using:

category:Category 1:name:keyword

Cheers,
David.
--
PriceTapestry.com

Submitted by Convergence on Sat, 2012-06-02 18:53

Hi David,

Spot on!

Thank you very much!