Active forum topics

©2006-2017 IAAI Software

Contact Us Privacy Policy

Advanced search form

Submitted by Ride on Fri, 2017-07-21 14:07.

Hi David,
I'd like to create an advanced search form that allows the visitor to select the search parameters using drop-down menus that will be automatically populated using some fields in the database.

I would also like to keep the default search form, as well as the default filters widget, so that you can apply additional filters using the widget after searching with the advanced search form.

Is this possible? I found some posts here about creating an advanced search form (example: node 211 and 432) but it's not exactly what I'm looking for.

Thank you!

Submitted by support on Sat, 2017-07-22 06:59.

Hello Ride,

The first step would be to add search filter support for the custom fields, and then to look at how you wanted to present the advanced search. Could you let me know one custom field name that you have added to your site and I'll describe the changes for version 3 using that field name so that it will be straight forward to apply for other fields..

Thanks,
David.
--
PriceTapestry.com

Submitted by Ride on Mon, 2017-07-24 10:31.

Hi David,
one custom field name is "diameter".
Thank you!

Submitted by support on Tue, 2017-07-25 07:08.

Hi,

Thanks - the first step would be to add the necessary filter code, and once that's all working then to look at how to present the filters as required. To add support for pto_diameterFilter first edit pto.php and look for the following code at line 976:

  array_push($vars, 'pto_brandFilter');

...and REPLACE with:

  array_push($vars, 'pto_brandFilter');
  array_push($vars, 'pto_diameterFilter');

Then edit pto_search.php and look for the following code at line 23:

  global $pto_brandFilter;

...and REPLACE with:

  global $pto_brandFilter;
  global $pto_diameterFilter;

And then the following code at line 64:

  $pto_brandFilter = (isset($pto_brandFilter)?$pto_brandFilter:"");

...and REPLACE with:

  $pto_brandFilter = (isset($pto_brandFilter)?$pto_brandFilter:"");
  $pto_diameterFilter = (isset($pto_diameterFilter)?$pto_diameterFilter:"");

And then the following code at line 103:

 if ($pto_brandFilter)
  {
    $priceWhere .= " AND brand = '".esc_sql($pto_brandFilter)."' ";
  }

...and REPLACE with:

  if ($pto_brandFilter)
  {
    $priceWhere .= " AND brand = '".esc_sql($pto_brandFilter)."' ";
  }
<code>
  if ($pto_diameterFilter)
  {
    $priceWhere .= " AND diameter = '".esc_sql($pto_diameterFilter)."' ";
  }

And then the following code at line 459:

  global $pto_brandFilter;

...and REPLACE with:

  global $pto_brandFilter;
  global $pto_diameterFilter;

And then the following code at line 477:

  if ($pto_brandFilter) $sortBaseHREF .= "&pto_brandFilter=".urlencode($pto_brandFilter);

...and REPLACE with:

  if ($pto_brandFilter) $sortBaseHREF .= "&pto_brandFilter=".urlencode($pto_brandFilter);
  if ($pto_diameterFilter) $sortBaseHREF .= "&pto_diameterFilter=".urlencode($pto_diameterFilter);

And then the following code at line 666:

  global $pto_brandFilter;

...and REPLACE with:

  global $pto_brandFilter;
  global $pto_diameterFilter;

And finally the following code at line 715:

      if ($pto_brandFilter) $navigationBaseHREF .= "&pto_brandFilter=".urlencode($pto_brandFilter);

...and REPLACE with:

      if ($pto_brandFilter) $navigationBaseHREF .= "&pto_brandFilter=".urlencode($pto_brandFilter);
      if ($pto_diameterFilter) $navigationBaseHREF .= "&pto_diameterFilter=".urlencode($pto_diameterFilter);

With that in place, make a test query e.g. "keywords" for something that will return results with diameter values in the database and when on the results page e.g.

http://www.example.com/shopping?pto_q=keywords

...append a test pto_diameterFilter value to check the functionality e.g.

http://www.example.com/shopping?pto_q=keywords&pto_diameterFilter=15

Cheers,
David.
--
PriceTapestry.com