Hi David In Search result Page can be possible to remove Search Filter condition
I take screen shot of one website for better understanding
check : {link saved}
technoarenasol
david filter name is not showing on removefilter
{link saved}
take a look at this
Hi,
Ah - I just realised that you are using the list version; so $brandFilter is an array, so would have to be displayed differently to show each currently active filter value. I also note that the button images/remove.gif is not yet present so don't forget to upload your image so that you can click to the remove the filter.. Have a go with:
<?php if ($priceWhere): ?>
<div class='removeFilters'>
<?php
if ($brandFilter) print "Filtered by brand: ".implode(",",$brandFilter)." <a href='".removeFilters(array("brandFilter"))."'><img border='0' src='/images/remove.gif' /></a>";
?>
</div>
<?php endif; ?>
Cheers,
David.
--
PriceTapestry.com
technoarenasol
Thanks David.Its working now but error on some pages
Link : {link saved}
Hi,
Use this alternative version of the removeFilters function to correct the warnings - this is due to list (array) filters rather than the single value versions...
<?php
function removeFilters($remove)
{
global $config_baseHREF;
global $q;
$href = $config_baseHREF."search.php?q=".urlencode($q);
$filters = array("minPrice","maxPrice","merchantFilter","categoryFilter","brandFilter","priceRange");
foreach($filters as $filter)
{
if ($GLOBALS[$filter] && !in_array($filter,$remove))
{
if (is_array($GLOBALS[$filter]))
{
foreach($GLOBALS[$filter] as $v)
{
$href .= "&".$filter."[]=".urlencode($v);
}
}
else
{
$href .= "&".$filter."=".urlencode($GLOBALS[$filter]);
}
}
}
return $href;
}
?>
Cheers,
David.
--
PriceTapestry.com
technoarenasol
Hi David.above code not working..
try this :
{link saved}
Hi technoarenasol;
removeFilters() function corrected above - this line:
if (is_array())
...should be:
if (is_array($GLOBALS[$filter]))
Cheers,
David.
--
PriceTapestry.com
Hi David, this can be implemented on the version 16/10A, with X to clear the individual filters applied.
Thanks
Giuseppe
Hello Giuseppe,
Sure - first add the following new code to the very top of html/searchfilters.php:
<?php
function removeFilters($remove)
{
global $config_baseHREF;
global $q;
$href = $config_baseHREF."search.php?q=".urlencode($q);
$filters = array("minPrice","maxPrice","merchantFilter","categoryFilter","brandFilter","priceRange");
foreach($filters as $filter)
{
if (isset($_GET[$filter]) && ($filter <> $remove))
{
$href .= "&".$filter."=".urlencode($_GET[$filter]);
}
}
return $href;
}
?>
And then to add [X] next to each of the filter labels to remove the filter, look for the following code at (now) line 59:
print "<label>".translate("Merchant")."<br />";
...and REPLACE with:
print "<label>".translate("Merchant").($merchantFilter?" [<a href='".removeFilters("merchantFilter")."'>X</a>]":"")."<br />";
And then the following code at line 99:
print "<label>".translate("Category")."<br />";
...and REPLACE with:
print "<label>".translate("Category").($categoryFilter?" [<a href='".removeFilters("categoryFilter")."'>X</a>]":"")."<br />";
And then the following code at line 128:
print "<label>".translate("Category")."<br />";
...and REPLACE with:
print "<label>".translate("Category").($categoryFilter?" [<a href='".removeFilters("categoryFilter")."'>X</a>]":"")."<br />";
And then the following code at line 157:
print "<label>".translate("Brand")."<br />";
...and REPLACE with:
print "<label>".translate("Brand").($brandFilter?" [<a href='".removeFilters("brandFilter")."'>X</a>]":"")."<br />";
And then the following code at line 184:
print "<label>".$config_currencyHTML." ".translate("from")."</label>";
...and REPLACE with:
print "<label>".$config_currencyHTML." ".translate("from").($minPrice?" [<a href='".removeFilters("minPrice")."'>X</a>]":"")"</label>";
And finally the following code at line 192:
print "<label>".$config_currencyHTML." ".translate("to")."</label>";
...and REPLACE with:
print "<label>".$config_currencyHTML." ".translate("to").($maxPrice?" [<a href='".removeFilters("maxPrice")."'>X</a>]":"")"</label>";
Cheers,
David.
--
PriceTapestry.com
Hi David,
many thanks.
I have this error
{code saved}
David, thanks for support!
Hi,
Sorry about that - the final two replacements were incorrect. I've updated the above post - to correct your html/searchfilters.php change line 125 as follows;
print "<label>".$config_currencyHTML." ".translate("from").($minPrice?" [<a href='".removeFilters("minPrice")."'>X</a>]":"")."</label>";
...and line 129:
print "<label>".$config_currencyHTML." ".translate("to").($maxPrice?" [<a href='".removeFilters("maxPrice")."'>X</a>]":"")."</label>";
Cheers,
David.
--
PriceTapestry.com
Hi technoarenasol,
The first thing I would do is to create a function that returns the current search URL but without the specified filter(s). To do this, add the following code to the top of your html/searchresults.php
<?php
function removeFilters($remove)
{
global $config_baseHREF;
global $q;
$href = $config_baseHREF."search.php?q=".urlencode($q);
$filters = array("minPrice","maxPrice","merchantFilter","categoryFilter","brandFilter","priceRange");
foreach($filters as $filter)
{
if ($GLOBALS[$filter] && !in_array($filter,$remove))
{
$href .= "&".$filter."=".urlencode($GLOBALS[$filter]);
}
}
return $href;
}
?>
The above function accepts an array of filter names, and then returns the current search URL with those filters removed.
You can detect whether any filters are in use by checking $priceWhere, and then and then you can check for any filter you wish to add a removal option for simply using an IF() statement on the filter value; so to create a banner using a DIV of class "removeFilters" have a go with something like this:
<?php if ($priceWhere): ?>
<div class='removeFilters'>
<?php
if ($brandFilter) print "Filtered by brand: ".$brandFilter." <a href='".removeFilters(array("brandFilter"))."'><img border='0' src='/images/remove.gif' /></a>";
?>
</div>
<?php endif; ?>
The above code assumes an image for your remove filter button as /images/remove.gif - simply change that in the above example if you already have an image of a different name in place, and add similar code within the IF construct for other filters you wish to add the remove option for...
Hope this helps!
Cheers,
David.
--
PriceTapestry.com