Announcement
Collapse
No announcement yet.
stripped_descrip not stripping
Collapse
X
-
Thanks, Nick. The first example wasn't quite what I was looking to do, but the second example what much closer.
-
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:
-
Originally posted by lesliekirk View PostAnother 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;",
the miva_html_strip function did not work with the HTML comments
The description is full of those HTML comments that Microsoft adds. Are there any other solutions?
Leave a comment:
-
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:
-
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;",
Leave a comment:
-
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:
-
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> },
- 1 like
Leave a comment:
-
Nick I think I did something wrong. When I updated the code toCode:<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>
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:
-
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>
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:
-
Originally posted by SidFeyDesigns View PostThis 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
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>
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]-->
Leave a comment:
-
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:
-
Originally posted by RTHOMASDESIGN View PostYou'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
Leave a comment:
-
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:
-
Originally posted by RTHOMASDESIGN View PostYou have &mvt:product:descrip; instead of &mvt:product:stripped_descrip;. Think that's it anyway.
Leave a comment:
-
You have &mvt:product:descrip; instead of &mvt:product:stripped_descrip;. Think that's it anyway.
Leave a comment:
Leave a comment: