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!
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%">
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
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>
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
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
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
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?
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
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
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
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