Announcement

Collapse
No announcement yet.

stripped_descrip not stripping

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

  • lesliekirk
    replied
    Thanks, Nick. The first example wasn't quite what I was looking to do, but the second example what much closer.

    Leave a comment:


  • Nick
    replied
    lesliekirk the miva_html_strip function will only strip out HTML entities. In order to remove special characters that appear you can use the glosub or glosub_array functions. Here is an example of the glosub_array function: https://gist.github.com/steveosoule/11458271

    You also may be able to use this code snippet or at least modify it to work in a way that you need: https://docs.miva.com/code-samples/remove-html

    Leave a comment:


  • lesliekirk
    replied
    Originally posted by lesliekirk View Post
    Another follow-up on this. I'm now using the product-json-id and am still having issues with MS crap not getting stripped out

    Code:
    <mvt:assign name="l.settings:product:stripped_descrip" value="miva_html_strip(l.settings:product:descrip, '')"/>
    "description": "&mvtj:product:stripped_descrip;",
    Am I going to need to use the long-winded code to fix this?
    I used this in the product-json-id and it is not removing all that MS crap. Nick's previous comment
    the miva_html_strip function did not work with the HTML comments
    still appears to hold true.

    The description is full of those HTML comments that Microsoft adds. Are there any other solutions?

    Leave a comment:


  • SidFeyDesigns
    replied
    lesliekirk Yes I would say that would be the more bulletproof solution.

    I just removed the <mvt:assign name="l.settings:product:stripped_descrip" value="substring_var(l.settings:product:stripped_d escrip, 1, 160)" /> line as not to limit the length of the decription.

    Going this route will also ensure that a store owner doesn't break anything in the future if they copy and paste from Microsoft Word and whatnot.

    Leave a comment:


  • lesliekirk
    replied
    Another follow-up on this. I'm now using the product-json-id and am still having issues with MS crap not getting stripped out

    Code:
    <mvt:assign name="l.settings:product:stripped_descrip" value="miva_html_strip(l.settings:product:descrip, '')"/>
    "description": "&mvtj:product:stripped_descrip;",
    Am I going to need to use the long-winded code to fix this?

    Leave a comment:


  • SidFeyDesigns
    replied
    lesliekirk not a problem at all.

    It's super weird that adding the meta tag with the stripped decription and removing the itemprop="description" attribute from the regular description made it disappear. Not quite sure why that would be happening.

    Either way I'm glad you were able to work it out.

    The JSON-LD is much nicer to work with once it's set up with all the right Miva variables and conditionals.

    Leave a comment:


  • lesliekirk
    replied
    Update, I think I have the product-json-id file working. I discovered an issue with the "brand"
    Code:
    "brand": {
    "@type": "Thing",
    <mvt:if expr="NOT ISNULL l.settings:product:customfield_values:customfields :brand">
    "name": "&mvtj:product:customfield_values:customfields:bra nd;"
    <mvt:else>
    "name": "&mvtj:global:store:name;"
    </mvt:if>
    },

    Needs to be changed to
    Code:
    "brand": {
    "@type": "Brand",
    <mvt:if expr="NOT ISNULL l.settings:product:customfield_values:customfields :brand">
    "name": "&mvtj:product:customfield_values:customfields:brand;"
    <mvt:else>
    "name": "&mvtj:global:store:name;"
    </mvt:if>
    },
    Thanks again, Nick!


    Leave a comment:


  • lesliekirk
    replied
    Nick I think I did something wrong. When I updated the code to
    Code:
    <mvt:comment>Strip any HTML from the product description.</mvt:comment>
    <mvt:assign name="l.settings:product:stripped_descrip" value="miva_html_strip(l.settings:product:descrip, '')"/>
    <meta itemprop="description" content="&mvte:product:stripped_descrip;" />
    <div class="x-flex-tabs__content">
    &mvt:product:descrip;
    </div>
    it caused the Product Description to disappear from the page.

    I am even more confused because the product-json-id file is there, active, and assigned to the PROD page. Shouldn't I see duplicate data being reported? Or do I need to remove all the Microdata meta tags and attributes from the HTML for it to be recognized?

    Leave a comment:


  • SidFeyDesigns
    replied
    Hi Leslie,

    What version of Shadows are you working on?

    Looking at PROD for Shadows 2 (whatever the last version was before 10.04), there is already a snippet for <meta itemprop="description" content="&mvte:product:stripped_descrip;" /> in the PROD Template, which means you should be able to just remove the itemprop from the description div in the Product Display Layout <div class="x-flex-tabs__content" REMOVE THIS(itemprop="description")>

    If that is not the case, you should be able to do something like this:

    Code:
    <mvt:comment>Strip any HTML from the product description.</mvt:comment>
    <mvt:assign name="l.settings:product:stripped_descrip" value="miva_html_strip(l.settings:product:descrip, '')"/>
    <meta itemprop="description" content="&mvte:product:stripped_descrip;" />
    <div class="x-flex-tabs__content" REMOVE THIS(itemprop="description")>
        &mvt:product:descrip;
    </div>
    Another thing to think about is switching to using the JSON-LD format rather than Microdata if you don't want to worry about breaking anything (cause invalid schema) when you need to move html around.

    https://developers.google.com/search...r-page-example

    You would of course need to remove all the Microdata meta tags and atrributes from the html, but once set up, it becomes it's own portion of code dedicated to the product schema.

    You would then be free to do whatever with the html that users actually see. It'll take a little bit of time to migrate but will likely be more flexible if a project calls for that.

    Re: fixing the descriptions.

    Fixing them would definitely help but the problem may come up again unless the site owner is taught not to copy and paste from Word and passes that info to any internal staff, which typically tends to be easier said than done.

    For that reason it may be more future proof to try that snippet I linked to in my previous post as long as it can also handle the Microsoft specific tags.

    I think the real fix is for the miva_html_strip() function to be updated to handle html comments and any other tags that it may not currently handle.

    Perhaps Brennan could also enlighten us on any other limits the miva_html_strip() function might have.

    Just my $0.02 on the matter.

    Hope this helps.

    Leave a comment:


  • lesliekirk
    replied
    Originally posted by SidFeyDesigns View Post
    This is a shot in the dark but check to see if there are any hard coded HTML comments in the descriptions.

    I recently ran into an issue that sounds similar to what you're running into while setting up a Google Shopping product feed.

    The site I was working on at the time had HTML comments in their descriptions that were used by Bill's PowerSearch module and the miva_html_strip function did not work with the HTML comments (not to be confused with <mvt:comment>).

    I ended up using a slightly modified version of this (quite large) snippet: https://docs.miva.com/code-samples/remove-html
    Hi Nick,

    I've finally had a moment to direct back on this and I think my issues stem from two problems. The product description for the "type Product description" is coming from
    Code:
    <div class="x-flex-tabs__content" itemprop="description">
    &mvt:product:descrip;
    </div>
    which is in the Product Display Layout portion of the PROD template. That leads me to ask how do I fix that location?

    The other issue is coming from exactly what you mentioned but in this case, it's Microsoft copy & paste hell:

    Code:
    <!--[if gte mso 9]><xml>
    <o:OfficeDocumentSettings>
    <o:AllowPNG/>
    <o:PixelsPerInch>96</o:PixelsPerInch>
    </o:OfficeDocumentSettings>
    </xml><![endif]-->
    I'm almost thinking it would be better to go in and fix all the descriptions than to continue chasing this rabbit down its hole.


    Leave a comment:


  • SidFeyDesigns
    replied
    This is a shot in the dark but check to see if there are any hard coded HTML comments in the descriptions.

    I recently ran into an issue that sounds similar to what you're running into while setting up a Google Shopping product feed.

    The site I was working on at the time had HTML comments in their descriptions that were used by Bill's PowerSearch module and the miva_html_strip function did not work with the HTML comments (not to be confused with <mvt:comment>).

    I ended up using a slightly modified version of this (quite large) snippet: https://docs.miva.com/code-samples/remove-html

    Leave a comment:


  • lesliekirk
    replied
    Originally posted by RTHOMASDESIGN View Post
    You're trying to render the product description without any HTML in "<meta itemprop="description" content="&mvte:product:stripped_descrip;" />" right?



    You'll likely need to reach out to Miva.
    -Ryan

    Yes. I'm thinking I may need to. First I need to look at a couple of the descriptions. Some have been copied and pasted directly from Word Doc hell, some have some simple HTML. I wonder if the Miva stripper can't handle all the crap that Word spews or if there might be a deeper issue?

    Leave a comment:


  • RTHOMASDESIGN
    replied
    You're trying to render the product description without any HTML in "<meta itemprop="description" content="&mvte:product:stripped_descrip;" />" right?

    Just tested on my end and the following outputs the product description with the HTML stripped as expected:
    <mvt:assign name="l.settings:product:stripped_descrip" value="miva_html_strip(l.settings:product:descrip, '')"/>
    &mvt:product:stripped_descrip;

    http://www.mivascript.com/item/mivas...tml_strip.html

    You'll likely need to reach out to Miva.
    -Ryan


    Leave a comment:


  • lesliekirk
    replied
    Originally posted by RTHOMASDESIGN View Post
    You have &mvt:product:descrip; instead of &mvt:product:stripped_descrip;. Think that's it anyway.
    Yes, I do because that is the snippet from within the Product Display Layout - it pulls in properly into the Offers description. The one that is pulling in all the HTML uses &mvt:product:stripped_descrip;

    Leave a comment:


  • RTHOMASDESIGN
    replied
    You have &mvt:product:descrip; instead of &mvt:product:stripped_descrip;. Think that's it anyway.

    Leave a comment:

Working...
X