Announcement

Collapse
No announcement yet.

echostrip_tags but leave <br>

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    echostrip_tags but leave <br>

    Normally when you write in Product Description and do two carriage returns when you 'inspect element' at the page preview your two returns become <br><br>
    Code:
    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus imperdiet, nulla et dictum interdum, nisi lorem egestas vitae scelerisque enim ligula venenatis dolor.
    
    Maecenas nisl est, ultrices nec congue eget, auctor vitae massa. Fusce luctus vestibulum augue ut aliquet. Nunc sagittis dictum nisi, sed ullamcorper ipsum dignissim ac. In at libero sed nunc venenatis imperdiet sed ornare turpis.
    
    Donec vitae dui eget tellus gravida venenatis. Integer fringilla congue eros non fermentum. Sed dapibus pulvinar nibh tempor porta.
    Becomes:
    Code:
    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus imperdiet, nulla et dictum interdum, nisi lorem egestas vitae scelerisque enim ligula venenatis dolor.
    <br>
    <br>
    Maecenas nisl est, ultrices nec congue eget, auctor vitae massa. Fusce luctus vestibulum augue ut aliquet. Nunc sagittis dictum nisi, sed ullamcorper ipsum dignissim ac. In at libero sed nunc venenatis imperdiet sed ornare turpis.
    <br>
    <br>
    Donec vitae dui eget tellus gravida venenatis. Integer fringilla congue eros non fermentum. Sed dapibus pulvinar nibh tempor porta.
    Where the product description is full of client entered code using the Sellerdeck 'style' buttons and you want to remove the ill advised formatting, using appearance 'Strip' or strip_tags leaves you with lots of strings of exclamation marks as the html is stripped but not the pairs of 'shrieks' that enclose each formatting. But I have not found it possible to remove the html tags and the exclamation marks and leave the <br>s.
    Code:
    <actinic:block php="true">
    strip_tags($input, '<br>');
    </actinic:block>
    doesn't work, <br> is removed as well.

    Here is my expression, how can I adapt it to strip tags but leave <br>?

    Code:
    <actinic:block php="true">
            $prodinput = '<actinic:variable encoding="perl" name="ProductDescription" selectable="false" />';
            $prodinputx = str_replace("!!","",$prodinput);
            echo strip_tags($prodinputx, '<br />');
            </actinic:block>
    Here is the sort of thing I am up against:
    Code:
    !!<<em>>!!!!<<strong>>!!!!<<span style='color: #993366;'>>!!ullamcorper ipsum dignissim!!<</span>>!!!!<</strong>>!!!!<</em>>!!
    Thank you!
    Jonathan Chappell
    Website Designer
    SellerDeck Website Designer
    Actinic to SellerDeck upgrades
    Graphicz Limited - www.graphicz.co.uk

    #2
    Have you considered a 3-stage process

    1. Find and replace <br> with "ZZZ999" or something which will not occur in normal text and doesn't look like a tag
    2. Strip tags
    3. Find and replace "ZZZ999" with <br> to reinstate the line breaks

    The first find and replace needs to look for all variations of <br>, <br /> etc.

    Comment


      #3
      There are problems in each of the lines of your code.

      1) You've used encoding="perl" when you put the description into a PHP variable. This will override the normal SD processing that converts newlines into <br> tags. So there were never any <br> tags to leave in place.

      2) Once you let SD do its normal encoding there's no need to strip !! (which would have been a bad idea anyway as you would be leaving spurious < and > chars in place).

      3) You've used <br /> in the strip_tags line and <br> is all that's needed.

      Try this:
      Code:
      <actinic:block php="true">
                  $prodinput = <<<ENDOFDESCRIPTION
      <actinic:variable name="ProductDescription" />
      ENDOFDESCRIPTION;
              echo strip_tags($prodinput, '<br>');
      </actinic:block>
      Note that the ENDOFDESCRIPTION; line must be tight up against the left margin.
      Norman - www.drillpine.biz
      Edinburgh, U K / Bitez, Turkey

      Comment

      Working...
      X