You are here:  » New filter to trim

New filter to trim

Submitted by sirmanu on Tue, 2018-09-04 07:31 in

Hi David.
Is it possible to add a new filter with in built php function trim to use the second parameter of this function?

I have some merchants where they always append the category name of the product. This is good, except when this category is empty. When this happens, I have strange names:

Good: Google Home - Electronics
Bad: Google Home -

So the filter only need to apply: trim($name, " - ");

I want to have the possibility to specify the second parameter in the filter, because other merchants use the '/'


Submitted by support on Tue, 2018-09-04 08:03

Sure - add to includes/filter.php to add a new Trim filter...

  /* trim */
  $filter_names["trim"] = "Trim";
  function filter_trimConfigure($filter_data)
    widget_textBox("Trim Chars","chars",FALSE,$filter_data["chars"],"",3);
  function filter_trimValidate($filter_data)
  function filter_trimExec($filter_data,$text)
    return trim($text,$filter_data["chars"]);

"Trim Chars" parameter as per $character_mask input to trim()...


Submitted by sirmanu on Tue, 2018-09-04 08:24

So fast this reply! You are great.
Thank you David, I'm going to test it out.