You are here:  » Filter option


Filter option

Submitted by wesse249 on Mon, 2015-08-24 19:00 in

Hello,

Between all my categories i have one category with only the letter L

I'd like to remove this category or replace it

When i do search and replace all categories with a L in the name are replaced als when i do explode.

Do you have a solution for it?

Thanks Jan Roel

Submitted by support on Tue, 2015-08-25 08:02

Hello Jan,

There is code in this comment for a Search and Replace RegExp filter which will let you do this. After adding the new filter, attach an instance to the Category field and use a Search expression of:

^L$

...and a Replace value of whatever you want to use instead.

In a regular expression (RegExp), ^ is the beginning of line anchor, and $ the end of line anchor so the above expression will match only a single uppercase "L" and nothing else...

Cheers,
David.
--
PriceTapestry.com

Submitted by wesse249 on Tue, 2015-08-25 20:11

Hello David,

I have a problem with the searchReplaceRegExp filter.

When you look at my testpage: http://vakantiehuisvoordelig.nl/category/Duitsland/ and click on the the jumpbox Regio/provincie you see the letter L.

I used the field "brand" for "Regio/provincie"

I filled in ^L$ at Search (Regular Expresion) and by replace i filled in nothing. Because i want to remove this letter completely.

When i run the import almost all of the field in the jumpbox Regio/provincie are removed and the import stopped with the message an error is occured.

I add this code:

  /*************************************************/
  /* searchReplaceRegExp */
  /*************************************************/
  $filter_names["searchReplaceRegExp"] = "Search and Replace (RegExp)";
  function filter_searchReplaceRegExpConfigure($filter_data)
  {
    print "Search (Regular Expresion):<br />";
    print "<input type='text' name='search' value='".widget_safe($filter_data["search"])."' />";
    widget_errorGet("search");
    print "<br /><br />";
    print "Replace:<br />";
    print "<input type='text' name='replace' value='".widget_safe($filter_data["replace"])."' />";
    widget_errorGet("replace");
  }
  function filter_searchReplaceRegExpValidate($filter_data)
  {
    if (!$filter_data["search"])
    {
      widget_errorSet("search","required field");
    }
  }
  function filter_searchReplaceRegExpExec($filter_data,$text)
  {
    return trim(preg_replace($filter_data["search"],$filter_data["replace"],$text));
  }

Submitted by support on Wed, 2015-08-26 07:25

Hello Jan,

My apologies the search expression requires delimiters with this format, have a go with:

/^L$/

Cheers,
David.
--
PriceTapestry.com

Submitted by wesse249 on Wed, 2015-08-26 11:35

Hi David,

When i add this /^L$/ the L isn't removed.

{link saved}

Greetings Jr

Submitted by support on Wed, 2015-08-26 12:04

Hello Jan,

I just did a full re-creation on my test server and it seemed to work OK - can you confirm the filter is attached to the Brand field, and the feed re-imported since applying the filter?

If still no joy, please could you email me; the link, the filename of the feed that the "L" value is coming from, and also from /admin/ > Tools > Backup and Restore a copy of the backup file with just "Filters" selected and I'll check that out for you...

Thanks,
David.
--
PriceTapestry.com