Announcement

Collapse
No announcement yet.

Stripping html tags within an <Actinic></Actinic> expression.

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

    Stripping html tags within an <Actinic></Actinic> expression.

    Code:
    <Actinic:PRICE_EXPLANATION PROD_REF="<actinic:variable name="ProductID" />" COMPONENTID=-1><actinic:variable name="RetailCustomerMessage" /></Actinic:PRICE_EXPLANATION>
    Client site has many hundreds of products and the Customer Messages in Prices are full of html tags which are breaking the new responsive layout. Adding encoding="strip" to <actinic:variable name="RetailCustomerMessage" /> does not strip the html tags presumably because the expression is within an <Actinic></Actinic> expression.

    How may I strip html in this circumstance?

    Thank you.
    Jonathan Chappell
    Website Designer
    SellerDeck Website Designer
    Actinic to SellerDeck upgrades
    Graphicz Limited - www.graphicz.co.uk

    #2
    Originally posted by graphicz View Post
    Client site has many hundreds of products and the Customer Messages in Prices are full of html tags
    Do you mean the variable itself (RetailCustomerMessage) contains styling tags, Jonathan?

    e.g. This is the <strong>message</strong>

    If so, I wrote a HTML stripping routine for our Catalog Export plug-in for this very purpose as I come across this problem a lot when exporting Full Descriptions, which can be littered with styling. I could apply that function to the part of the DB storing the price messages if I've understood you correctly.
    Andy Barrow
    http://www.codepath.biz
    T: 0161 870 6355

    Accredited Sellerdeck development partners since 2004.
    Data import / export and catalog management plug-ins.

    Comment


      #3
      Yes Andy. And lots of it!
      That certainly sounds like a plan, but how involved is it?
      Jonathan Chappell
      Website Designer
      SellerDeck Website Designer
      Actinic to SellerDeck upgrades
      Graphicz Limited - www.graphicz.co.uk

      Comment


        #4
        Originally posted by graphicz View Post
        Yes Andy. And lots of it!
        That certainly sounds like a plan, but how involved is it?
        Very straightforward if you don't want to be selective. It simply removes all text between and including <> pairs.
        Andy Barrow
        http://www.codepath.biz
        T: 0161 870 6355

        Accredited Sellerdeck development partners since 2004.
        Data import / export and catalog management plug-ins.

        Comment


          #5
          Try replacing:
          Code:
          <actinic:variable name="RetailCustomerMessage" />
          WIth:
          Code:
          <actinic:block php="true">echo strip_tags('<actinic:variable name="RetailCustomerMessage" encoding="perl" selectable="false" />');</actinic:block>
          Works here when I try it.
          Norman - www.drillpine.biz
          Edinburgh, U K / Bitez, Turkey

          Comment


            #6
            That's neat, Norman. I was thinking of physically removing the tags from the data (as I hate to see design and content mixed up like that anyway) but that looks like a quicker fix.
            Andy Barrow
            http://www.codepath.biz
            T: 0161 870 6355

            Accredited Sellerdeck development partners since 2004.
            Data import / export and catalog management plug-ins.

            Comment


              #7
              You could also fix them for good by exporting the content tree (File / Export). Then look for all lines like:
              Code:
              Price,Retail,24000,0,1,1,"","<b>Wowza</b>",0
              And strip any tags from such lines. A good text editor that can do regexp type search/replacements should be able to do this in a few clicks.
              Norman - www.drillpine.biz
              Edinburgh, U K / Bitez, Turkey

              Comment


                #8
                Norman's inline fix is probably better for a client site that will be handed back as it will deal with future bad practice by the client!

                Thank you both very much.

                BTW Andy, is your database fix publishable or is it purchasable? Thanks!
                Jonathan Chappell
                Website Designer
                SellerDeck Website Designer
                Actinic to SellerDeck upgrades
                Graphicz Limited - www.graphicz.co.uk

                Comment


                  #9
                  From: http://www.digocodigo.com/2012/03/co...d-and.html?m=1

                  Code to strip html tags in Notepad++ and leave only text

                  Select "Regular Expression" in Search Mode. Enter [<].*?> in Find What field and leave the Replace With field empty. Note that you need to have version 5.9 of Notepad++ for the ? operator to work.
                  Jonathan Chappell
                  Website Designer
                  SellerDeck Website Designer
                  Actinic to SellerDeck upgrades
                  Graphicz Limited - www.graphicz.co.uk

                  Comment


                    #10
                    Originally posted by graphicz View Post
                    Andy, is your database fix publishable or is it purchasable? Thanks!
                    It is not a stand-alone script but part of a larger compiled app that performs various other functions on the data.
                    Andy Barrow
                    http://www.codepath.biz
                    T: 0161 870 6355

                    Accredited Sellerdeck development partners since 2004.
                    Data import / export and catalog management plug-ins.

                    Comment


                      #11
                      Watch out if using Jonathan's bit of Notepad++ code. This will strip all HTML tags (indeed any text between < and the next >) from the entire document. Exported sites will probably contain many lines with tags that you'll need to keep.

                      You should only apply such an action to the lines beginning "Price,Retail,".
                      Norman - www.drillpine.biz
                      Edinburgh, U K / Bitez, Turkey

                      Comment


                        #12
                        Running into more difficulties with the client’s excessive use of html in the content dialogues breaking the new layout I realised it was usually due to an un-closed tag especially in product description.

                        I found the file htmlfixer.class.php (Giulio Pons, http://www.barattalo.it) and this has largely fixed the issue:

                        Code:
                        <div class="product-text">
                        		<actinic:block php="true" selectable="false" >
                        		include_once 'htmlfixer.class.php'; 
                        		$dirty_html = '<actinic:variable name="ProductDescription" encoding="perl" selectable="false" />';
                        		$dirty_html = str_replace("!!","","$dirty_html");
                        		$a = new HtmlFixer();
                        		$clean_html = $a->getFixedHtml($dirty_html);
                        		echo $clean_html;
                        		</actinic:block></div>
                        Such that a product description thus:
                        Code:
                        !!<<span style='font-size: 14px;'>>!!
                        !!<<strong>>!!A 2-part accessory which can be attached to the end of our 6mm and 8mm !!<<a href="Polypropylene_Shock_Cord_Reels.html">shock cord</a>>!! to create a handy hook fixing.
                        
                        Supplied as single fixing (shock cord supplied separately)
                        Colour : Black
                        
                        
                        Minimum force daN required to remove hook from cable:
                        8mm dia. cable PE covering 30 daN
                        Tolerance +/- 15%!!<</span>>!!
                        Becomes:

                        Code:
                        <> <>A 2-part accessory which can be attached to the end of our 6mm and 8mm <shock cord> to create a handy hook fixing. Supplied as single fixing (shock cord supplied separately) Colour : Black Minimum force daN required to remove hook from cable: 8mm dia. cable PE covering 30 daN Tolerance +/- 15%>
                        (Shock cord displays correctly as a hyperlink. and the layout all works correctly)

                        However, I am unable to remove the extraneous < and >.

                        I would be very grateful for a nudge in the right direction.

                        Thank you
                        Jonathan Chappell
                        Website Designer
                        SellerDeck Website Designer
                        Actinic to SellerDeck upgrades
                        Graphicz Limited - www.graphicz.co.uk

                        Comment


                          #13
                          Try replacing
                          Code:
                          		$dirty_html = str_replace("!!","","$dirty_html");
                          With:
                          Code:
                          		$dirty_html = str_replace("!!<","","$dirty_html");
                          		$dirty_html = str_replace(">!!","","$dirty_html")
                          ;
                          Norman - www.drillpine.biz
                          Edinburgh, U K / Bitez, Turkey

                          Comment


                            #14
                            I did try that but adding < or > made the expression red in SD so I assumed it was incorrect and that the < and > needed escaping somehow.

                            In fact it works perfectly, thank you Norman!



                            Full code:

                            Code:
                            <actinic:block php="true" selectable="false" >
                            		include_once 'htmlfixer.class.php'; 
                            		$dirty_html = '<actinic:variable name="ProductDescription" encoding="perl" selectable="false" />';
                            		$dirty_html = str_replace("!!<","","$dirty_html");
                            		$dirty_html = str_replace(">!!","","$dirty_html");
                            		$a = new HtmlFixer();
                            		$clean_html = $a->getFixedHtml($dirty_html);
                            		echo $clean_html;
                            		</actinic:block></div>
                            Credit:
                            "HTML FIXER v.2.05 15/07/2010
                            clean dirty html and make it better, fix open tags
                            bad nesting, bad quotes, bad autoclosing tags.
                            by Giulio Pons, http://www.barattalo.it"

                            And of course Norman who as on so very many occasions makes it work!
                            Thank you.
                            Jonathan Chappell
                            Website Designer
                            SellerDeck Website Designer
                            Actinic to SellerDeck upgrades
                            Graphicz Limited - www.graphicz.co.uk

                            Comment


                              #15
                              This works for me:
                              Code:
                              <div class="product-text">
                              	<actinic:block php="true" selectable="false" >
                              		include_once 'htmlfixer.class.php'; 
                              		$dirty_html = <<<ENDOFDESCRIPTION
                              		<actinic:variable name="ProductDescription" />
                              ENDOFDESCRIPTION;
                              		$a = new HtmlFixer();
                              		echo $a->getFixedHtml($dirty_html);
                              	</actinic:block>
                              </div>
                              Note that I've used HEREDOC syntax to get the description into a string and this requires you to put ENDOFDESCRIPTION; against the left margin (no indentation allowed for the end of a HEREDOC statement). We're using the description after SD generates it so there's no need to remove !!< and >!!.
                              Norman - www.drillpine.biz
                              Edinburgh, U K / Bitez, Turkey

                              Comment

                              Working...
                              X