You are here:  » Search Filters Widget does not appear on my website


Search Filters Widget does not appear on my website

Submitted by djkkjd on Thu, 2012-06-07 14:40 in

Hi,

The 'Search Filters Widget' does not show up on my website. All other widget show up on my website.
Any advice how the 'Search Filters Widget' get to working?

Thank you!

Submitted by support on Thu, 2012-06-07 15:07

Hi,

Thanks for the site and admin link, i've identified the problem straight away which is to do with the widget area to which the search filters widget was added (I assume the left-hand widget area) being rendered before the main search; so the variables required by the widget have not yet been set.

I need to re-create this scenario on my test server to work out a proper fix so I'll get onto that and let you know be email as well as update this thread for the benefit of other users as soon as I have incorporated the solution into the distribution...

Cheers,
David.
--
PriceTapestry.com

Submitted by djkkjd on Tue, 2012-06-12 23:43

Hi,

I temporarily added the 'Search Filters Widget' to a other widget in WP, so it works temporarily.

Question. Is it possible to to add extra search option to the 'Search Filters Widget'? I like to have a option like 'colors'.

And is it possible to display the option 'colors' only in catagories where colors are used.

I already added extra database field like in http://www.pricetapestry.com/node/3094

Do I only need to copy and modify this code? If I do it doesn't work probably.

<%IF_CATEGORIES%
<br />By Category:
<br /><select name='pto_categoryFilter'>
  <option value=''>All</option>
  %CATEGORIES%
</select>
%ENDIF_CATEGORIES%">

Submitted by support on Wed, 2012-06-13 09:46

Hi,

Yes this can be done - it basically involves complete duplication of categoryFilter related code throughout pto.php and pto_search.php, using colorFilter. In line with the other filters, it will only show if there are products with a color value in the result set.

Because I'm familiar with the code I've done this quickly for you based on the latest distribution and will email the files to you in just a moment (I've assumed the new field in the database is "color"). With the modified files in place the additional code exactly as you assumed added to the sidebar filters widget HTML template will do the trick...

Cheers,
David.
--
PriceTapestry.com

Submitted by djkkjd on Wed, 2012-06-13 13:17

Hi,

I got now this code. And uploaded the files that you sent by mail. But the 'search filter widget' displays in my website: the text %IF_COLOR% and %ENDIF_COLOR% . And doesnt show any result in the in the 'color' drop down menu.

See the link for result {link saved}

Did I something wrong?

<div class='pto_search_filters_widget'>
<form method='GET' action='%ACTION%'>
<input type='hidden' name='pto_q' value='%PTO_Q%' />
%IF_MERCHANTS%
By Merchant:
<br /><select name='pto_merchantFilter'>
  <option value=''>All</option>
  %MERCHANTS%
</select>
%ENDIF_MERCHANTS%
%IF_CATEGORIES%
<br />By Category:
<br /><select name='pto_categoryFilter'>
  <option value=''>All</option>
  %CATEGORIES%
</select>
%ENDIF_CATEGORIES%
%IF_BRANDS%
<br />By Brand:
<br /><select name='pto_brandFilter'>
  <option value=''>All</option>
  %BRANDS%
</select>
%ENDIF_BRANDS%
%IF_COLOR%
<br />Colors:
<br /><select name='pto_colorFilter'>
  <option value=''>All</option>
  %COLOR%
</select>
%ENDIF_COLOR%
<br />By Price:
<br />
<input type='text' size='4' name='pto_minPrice' value='%PTO_MINPRICE%' />
to
<input type='text' size='4' name='pto_maxPrice' value='%PTO_MAXPRICE%' />
<br />
<input type='submit' value='Apply' />
</form>

Submitted by support on Wed, 2012-06-13 13:24

Hi,

I had persisted the use of plural text in the placeholder code, have a go with:

%IF_COLORS%
<br />Colors:
<br /><select name='pto_colorFilter'>
  <option value=''>All</option>
  %COLORS%
</select>
%ENDIF_COLORS%

...that should be all it is...

Cheers,
David.
--
PriceTapestry.com

Submitted by djkkjd on Sun, 2012-06-24 18:59

Thanks for the great help!

Got one more question.

Can I create multiple 'Search Filters Widget' ? For some catogory i want customized filters.

Example:

-Search Filters Widget 1
--ColorFilter

-Search Filters Widget 2
-- ThicknessFilter
-- SpeedFilter

-Search Filters Widget 3
--MaterialFilter

Submitted by support on Mon, 2012-06-25 17:02

Hi,

The easiest thing to do is probably to add a new field to the Sidebar Filters widget, containing a comma separated list of which filters to display.

In pto_search.php (based on distribution version) look for the following code at line 944:

$title = esc_attr($instance["title"]);
print "<p><label for='".$this->get_field_id('title')."'>"._e("Title:")." <input class='widefat' id='".$this->get_field_id('title')."' name='".$this->get_field_name('title')."' type='text' value='".htmlentities($title,ENT_QUOTES,get_settings("blog_charset"))."' /></label></p>";

...and then ADD the following lines to add the new "Show" field to the widget:

$show = esc_attr($instance["show"]);
print "<p><label for='".$this->get_field_id('show')."'>"._e("Show:")." <input class='widefat' id='".$this->get_field_id('show')."' name='".$this->get_field_name('show')."' type='text' value='".htmlentities($show,ENT_QUOTES,get_settings("blog_charset"))."' /></label></p>";

Next, look for the following code at line 936:

$instance["title"] = strip_tags($new_instance["title"]);

...and then ADD:

$instance["show"] = $new_instance["show"]

With that in place, within the main filter code each filter can be displayed conditionally based on a test of the "show" value using strpos. For example, look for where the Merchant Filter is conditionally displayed based on the following code starting at line 846:

$sql = "SELECT DISTINCT(merchant) FROM `".$pto_config_databaseTablePrefix."products` WHERE ".$pto_searchWhere." ORDER BY merchant";
if ($numRows = $wpdb->query($sql))

...and REPLACE with:

$sql = "SELECT DISTINCT(merchant) FROM `".$pto_config_databaseTablePrefix."products` WHERE ".$pto_searchWhere." ORDER BY merchant";
if ($numRows = $wpdb->query($sql) && (stripos($instance["show"],"merchant")!==FALSE))

...and apply similar to the other sections of identical code save for the filter field; then you can specify which filters to display in any instance of the filter using, for example

thickness,speed

Cheers,
David.
--
PriceTapestry.com

Submitted by djkkjd on Fri, 2012-07-13 14:58

Hi,Thanks for the comment!

I implemented the code, unfortunately I don’t understand it completely.

The 'Search Filter Widget' now only displays the price option, other filters are now hided, becauses of the added code.

You talk about a 'add a new field to the Sidebar Filters widget, containing a comma separated'
Do I need and if so how to modify the code in wp/settings/PriceTapestry.org/html/maim/Search Filters Widget? Or modify something in pto_search.php?

Submitted by support on Fri, 2012-07-13 18:25

Hi,

If you could perhaps email me your modified pto_search.php and also from your Price Tapestry installation config.advanced.php I'll check it all out and reply with example filter configuration to do as described above...

Cheers,
David.
--
PriceTapestry.com

Submitted by newpbc on Thu, 2013-01-17 15:56

Hi David

Was there ever a solution found for search filters in a left sidebar if not no worries as I may use a new theme layout soon anyway

Submitted by support on Thu, 2013-01-17 15:59

Hi,

Yes! It will be included in the version update later this month, but if you would like me to patch it into your current files if they're otherwise working well email me your pto,php and pto_search.php and I'll do that for you...

Cheers,
David.
--
PriceTapestry.com