You are here:  » Allowing line breaks in HTML?

Support Forum



Allowing line breaks in HTML?

Submitted by daem0n on Tue, 2009-02-24 06:15 in

A new question for you! I have a feed that has the  <br> or <br /> tags in it. I want to allow line breaks because otherwise the product description gets jumbled up a bit. I know that the tapestry and normalize functions get rid of HTML code. Is there anyway that I can allow just that one tag to be allowed in the description field?

Thanks for any ideas!

-Joe

Submitted by support on Tue, 2009-02-24 08:59

Hi Joe,

Sure - the strip_tags call can be modified to permit BR, and then after that, the < > and / symbols must be allowed by the normalise function. To do this, look for the following code beginning at line 161 of includes/admin.php

    if ($admin_importFeed["field_description"])
    {
      $record[$admin_importFeed["field_description"]] = strip_tags($record[$admin_importFeed["field_description"]]);
      $record[$admin_importFeed["field_description"]] = tapestry_normalise($record[$admin_importFeed["field_description"]],",'\'\.%!");
    }

...and REPLACE this with:

    if ($admin_importFeed["field_description"])
    {
      $record[$admin_importFeed["field_description"]] = strip_tags($record[$admin_importFeed["field_description"]],"<br>");
      $record[$admin_importFeed["field_description"]] = tapestry_normalise($record[$admin_importFeed["field_description"]],"<>\/,'\'\.%!");
    }

Cheers,
David.

Submitted by daem0n on Wed, 2009-02-25 05:35

Hi David,

Works great and connected a synapse in my brain! haha ;)

Seriously it did make me realize a lot about the PHP filter, so thanks!

-Joe

Submitted by mgmedia on Thu, 2011-04-14 20:26

Hi David ,

I've been looking to do this as some products on my site have stupidly long text that is meant to be broken up into sections. I can't find the part that you mention anywhere though for me to change this. I'm assuming it's because I have a newer version, so how would this be done now please?

Thanks

Ben

Submitted by support on Fri, 2011-04-15 09:02

Hi Ben,

The latest distribution doesn't strip tags automatically as there is now a Strip HTML filter available is HTML needs to be removed from the description; so it sounds as if your long descriptions don't have HTML in place otherwise they should display correctly.

Is there any indication in the description as to where line breaks (paragraphs) should be inserted?

Cheers,
David.
--
PriceTapestry.com