You are here:  » remove at end of name

Support Forum



remove at end of name

Submitted by marco on Mon, 2012-05-14 09:40 in

Hello,

I have a feed where a "." is placed at the end of the name of lot of items (the name is written like a sentence).
I would like to remove this character, but only at the end (if present).
How can this be done with a filter or general setting?

Best Regards,
Marco

Submitted by support on Mon, 2012-05-14 10:19

Hi Marco,

A new "Trim" filter will do the trick - add the following code to your html/filter.php just before the closing PHP tag:

  /*************************************************/
  /* Trim */
  /*************************************************/
  $filter_names["trim"] = "Trim";
  function filter_trimConfigure($filter_data)
  {
    print "Additional Chars:<br />";
    print "<input type='text' name='chars' value='".widget_safe($filter_data["chars"])."' />";
  }
  function filter_trimValidate($filter_data)
  {
  }
  function filter_trimExec($filter_data,$text)
  {
    return trim($text,$filter_data["chars"]);
  }

With that in place, add a new Trim filter to the Product Name field, and in the Additional Chars field enter "." (without the quotes). trim() by default just trims space characters...

Cheers,
David.
--
PriceTapestry.com

Submitted by marco on Mon, 2012-05-14 13:22

Works perfect, thanks David.

Cheers,
Marco

Submitted by Convergence on Mon, 2013-02-25 15:16

Hi David,

Can this be modded to include quotation marks at the beginning and end of the product name?

See a lot of quoation marks added when there is a measurement in the product name, example:

"42"" Blue Widget"

We do a search replace for the double quotation marks but are unable to remove the start and end quotation marks, example:

"42" Blue Widget"

Thanks!

Submitted by support on Mon, 2013-02-25 17:43

Hi,

Normally, quotation marks beginning and end of a field would indicate that the feed was registered without quoted-text being auto-detected. In the first instance, try re-registering the affected feed but on Feed Registration Step 1, instead of accepting the auto-detected format string select the correct format from the drop-down box, e.g. "Quoted Text - Header Row - Comma Separated".

That should be all it is - but if not, then the above filter can be used without modification, and in the Extra Chars box on the configuration page for the filter, simply enter a double quotes " on its own to strip that character from before / after the field...

Cheers,
David.
--
PriceTapestry.com