You are here:  » Strip HTML does not work or how does it work?


Strip HTML does not work or how does it work?

Submitted by kempo on Thu, 2010-09-16 20:26 in

Hi David,
I have put a STRIP HTML filter to my product descriptions and allowed just tags. But it does not work. Could you please check it at the following URL: {link saved}
Cheers,
Kempo

Submitted by support on Fri, 2010-09-17 08:27

Hi Kempo,

The problem is that the HTML is actually entity encoded within the feed; which is why it appears as literal HTML on your pages rather than being interpreted as actual HTML.

To fix this, first remove the Strip HTML filter, and insert 2 Search and Replace filters on the Description field as follows:

Search: <
Replace: <

Search: &gt;
Replace: >

And then finally your Strip HTML filter:

Allowable Tags:

As filters are applied in the order that they were created; the above will have the effect of first first turning the entity encoded HTML back into "normal" HTML, and then Strip Tags should work...!

Cheers,
David.
--
PriceTapestry.com

Submitted by kempo on Fri, 2010-09-17 18:39

Hi David,
Thank you very much for the information of the reason of not working. Instead of search and replace I wrote the following filter and now it works as I exactly want:

  /*************************************************/
  /* HTML ENTITY DECODE */
  /*************************************************/
  $filter_names["EntityDecode"] = "HTML Entity Decode";
  function filter_EntityDecodeConfigure($filter_data)
  {
    print "<p>There are no additional configuration parameters for this filter.</p>";
  }
  function filter_EntityDecodeValidate($filter_data)
  {
  }
   function filter_EntityDecodeExec($filter_data,$text)
  {
    return html_entity_decode($text);
  }

Cheers,

Kempo