Announcement

Collapse
No announcement yet.

Stripping HTML from Product Description

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

    Stripping HTML from Product Description

    I have a website that has content imported from an external source. The issue with the Content Management System used is that it adds unwanted HTML. They're currently working on a fix.

    In the meantime I've come up with a simple script:

    Code:
    <actinic:block php="true" >
        $input = 'This is a test<head><br><h1></h1>';
        $a = strip_tags($input);
        $b = strip_tags($input, "<br><ul><li>");
        echo $b;
    </actinic:block>
    Whereby it strips all HTML apart from the tags stated in variable $b

    This all works fine. The issue I have is as soon as add the Product Description field it runs, but the output is:

    !!!!

    Which I assume relates to the !!< and >!! in the variable declaring there's HTML in the full description.

    Has anybody got any ideas how can make work? Or maybe have a better solution?

    #2
    Does Right Clicking on the ProductDescription variable and choosing "stripHTML" option not fix it for you?
    Fergus Weir - teclan ltd
    Ecommerce Digital Marketing

    SellerDeck Responsive Web Design

    SellerDeck Hosting
    SellerDeck Digital Marketing

    Comment


      #3
      Hi Fergus,

      Sadly can't use that as need it to bring thru <br /> and <ul>

      Comment


        #4
        Weirdly seems to be working now simply changing ' to "" around ProductDescription

        Code:
        <actinic:block php="true" >
        
            $input = "<actinic:variable name="ProductDescription" />";
            $a = strip_tags($input);
            $b = strip_tags($input, "<h1><em>");
            echo $b; 
        </actinic:block>

        Comment


          #5
          Hmmm - I'd be wary of that Garry. If you're not using "Quoted Perl" then you risk errant apostrophes in the description field breaking the PHP parsing and giving you a funky warning on some products.

          The problem you have is you want SellerDeck to parse the product description and the embedded HTML AND be able to strip out selected tags?
          The issue with this is that by dropping the variable into a PHP variable you are removing the ability to allow Sellerdeck to parse the field appropriately (unless you leave it as it is in your last post, and risk the issues highlighted!).
          Fergus Weir - teclan ltd
          Ecommerce Digital Marketing

          SellerDeck Responsive Web Design

          SellerDeck Hosting
          SellerDeck Digital Marketing

          Comment


            #6
            Yeah is risky.

            It's only mean't to be temporary until the CMS company have fixed the import issue.

            Comment


              #7
              Better (simpler, quotes in description safe and won't error on the Design tab):
              Code:
              <actinic:block php="true" >
                  echo strip_tags('<actinic:variable name="ProductDescription" encoding="perl" selectable="false" />', '<h1><em>');
              </actinic:block>
              Norman - www.drillpine.biz
              Edinburgh, U K / Bitez, Turkey

              Comment


                #8
                Thanks Norman will give that ago

                Comment

                Working...
                X