You are here:  » Configure Filter - Search and Replace

Support Forum



Configure Filter - Search and Replace

Submitted by shopfinder on Wed, 2010-03-24 22:02 in

Hello,

it is possible to replace an empty field with a price like 5.95.

Thanks for an anwser.

Kevin

Submitted by support on Wed, 2010-03-24 22:11

Hi Kevin,

It would be straight forward to modify the Search and Replace filter to have that behaviour. Firstly, in includes/filter.php, look for the following code on line 28:

widget_errorGet("search");

...and either comment out or delete that line. That will enable the filter to be configured with an empty Search field.

Next, look for the following code beginning at line 47:

  function filter_searchReplaceExec($filter_data,$text)
  {
    return trim(str_replace($filter_data["search"],$filter_data["replace"],$text));
  }

...and REPLACE with this new version to make Search and Replace work as you describe:

  function filter_searchReplaceExec($filter_data,$text)
  {
    if ($filter_data["search"])
    {
      return trim(str_replace($filter_data["search"],$filter_data["replace"],$text));
    }
    else
    {
      return $filter_data["replace"];
    }
  }

Hope this helps!

Cheers,
David.

Submitted by shopfinder on Thu, 2010-03-25 08:15

Hello David,

it works fine.
But on line 43 i have to disable the code for the search field valdiation.

Thanks Kevin