You are here:  » Add Search Keyword in clear filter

Support Forum



Add Search Keyword in clear filter

Submitted by technoarenasol on Mon, 2012-10-22 09:02 in

Hi

can possible to add search keyword in remove filter ..I already added brand,sub-category in remove filter.Now i want add search query keyword in to remove filter.

Submitted by support on Mon, 2012-10-22 11:38

Hi Amin,

In the removeFilters() function that you added from this thread, where you have this line:

    $href = $config_baseHREF."search.php?q=".urlencode($q);

...REPLACE that with:

    if(in_array("q",$remove))
    {
      $href = $config_baseHREF."search.php?q=bw:";
    }
    else
    {
      $href = $config_baseHREF."search.php?q=".urlencode($q);
    }

You'll then be able to use the function for "q" in exactly the same way as your existing filters; in which case the search URL will be returned with q as "bw:" which is the search that returns all products (so other filters still apply of course)...

Cheers,
David.
--
PriceTapestry.com

Submitted by technoarenasol on Sun, 2012-11-04 12:23

technoarenasol

Hi I add code for search keyword filter but its bot working.

<?php
  function removeFilters($remove)
  {
    global $config_baseHREF;
    global $q;
    if(in_array("q",$remove))
    {
      $href = $config_baseHREF."search.php?q=bw:";
    }
    else
    {
      $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;
  }
?>

Submitted by support on Mon, 2012-11-05 12:01

Hi Amin,

Can you post the section of code you added that generates the link for the user to clear the keyword from the current search...

Thanks!
David.
--
PriceTapestry.com