Announcement

Collapse
No announcement yet.

miva_html_strip runs strings together

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

    miva_html_strip runs strings together

    I've noticed with the rich text editor on custom product fields (and likely elsewhere) that pressing the enter key results in div tags.

    For example, if I type "test", click the enter key, then type "test2" I end up with:

    Code:
    test<div>test2</div>
    But, if I run this through the miva_html_strip function with an empty string for allowed tabs, I get the two words run together as "testtest2" instead of "test test2".

    Any suggestions? This is specifically related to the rich text editor, so please don't say "put a space after each word before you press the enter key" :)

    Thanks,
    Susan
    Susan Petracco
    NetBlazon

    1.866.400.2444

    _____________________________________________

    Like us on Facebook

    #2
    That is the default functionality of the native Miva text editor.

    If you use SHIFT + ENTER the editor will add a <br> tag rather than wrap in a <div>

    Will that work?
    Nicholas Adkins
    Technical Training Specialist / Miva, Inc.
    [email protected]
    https://www.miva.com/mivalearn

    Comment


      #3
      Nick, not really, as either way requires the user to be smarter than I'd like. Ideally the function would be able to replace a tag with a single space, instead of just running together any contents within. But thanks for the idea and LMK if you have thoughts on a way to make that function do what I want it to.

      Somewhere I have a function that manually removes tags, and I may just use that instead.
      Susan Petracco
      NetBlazon

      1.866.400.2444

      _____________________________________________

      Like us on Facebook

      Comment


        #4
        What would be the down side of having miva_html_strip replace any html tag it removes with a space? Or having an additional parameter to specify that result?
        Bruce Golub
        Phosphor Media - "Your Success is our Business"

        Improve Your Customer Service | Get MORE Customers | Edit CSS/Javascript/HTML Easily | Make Your Site Faster | Get Indexed by Google | Free Modules | Follow Us on Facebook
        phosphormedia.com

        Comment


          #5
          It would be outside the scope of the function. The function is only meant to strip HTML, nothing else. With that being said, I'm not sure of a good solution for what you are trying to do either. I'll let you know if I come up with anything.
          David Carver
          Miva, Inc. | Software Developer

          Comment


            #6
            Thanks. That's ok. It's just an unfortunate side effect.
            Susan Petracco
            NetBlazon

            1.866.400.2444

            _____________________________________________

            Like us on Facebook

            Comment


              #7
              I used this in a feed recently. https://docs.miva.com/code-samples/remove-html

              The site had a bunch of html comments in the product descriptions that the miva_html_strip did not handle well.

              You could change lines 20 and 25 from this:
              Code:
              <mvt:assign name="l.stripped_descrip" value="glosub(l.stripped_descrip,'<','')" />
              to this (Note the space between the second set of double quotes):
              Code:
              <mvt:assign name="l.stripped_descrip" value="glosub(l.stripped_descrip,'<',' ')" />
              or this:
              Code:
              <mvt:assign name="l.stripped_descrip" value="glosub(l.stripped_descrip,'<',asciichar(32))" />
              Lines 34 and 35 take care of double and tripple spaces.

              Line 36 can be removed if you don't need to cap it at a certain character limit.


              You'll just want to add l.settings: to all the l.stripped_descrip variables in that snippet in the link.

              I had trouble with it working without using .settings.
              Last edited by SidFeyDesigns; 06-06-23, 01:26 PM.
              Nick Harkins
              www.loveisarose.com
              *Web Developer
              *Miva
              *Google Analytics, Search Console, Tag Manager, Merchant Center, Ads

              Comment


                #8
                Love it! Thanks Nick.
                Last edited by netblazon; 07-10-23, 09:36 AM.
                Susan Petracco
                NetBlazon

                1.866.400.2444

                _____________________________________________

                Like us on Facebook

                Comment


                  #9
                  Not a problem Susan.

                  I also just realized why the leaving out the .settings wasn't working... It was because I removed line 36...

                  That's the local variable that can be used to display the output of the code in the conditionals.

                  So if you don't want to limit the characters, you could leave line 36 and just change it from this:
                  Code:
                  <mvt:assign name="l.settings:stripped_descrip" value="substring_var(l.stripped_descrip, 1, 160)" />
                  to this:
                  Code:
                  <mvt:assign name="l.settings:stripped_descrip" value="l.stripped_descrip" />
                  Sorry for the confusion. Must not have had enough coffee that day... Either way will work though.

                  -Nick
                  Last edited by SidFeyDesigns; 06-06-23, 01:47 PM.
                  Nick Harkins
                  www.loveisarose.com
                  *Web Developer
                  *Miva
                  *Google Analytics, Search Console, Tag Manager, Merchant Center, Ads

                  Comment

                  Working...
                  X