Magento Snippet code in CMS not working with double curly braces {{}}
-
15-04-2021 - |
Domanda
My 3rd party plugin company ask me to Snippet in this code to my CMS page. but Magento did translate something else for the double curly braces.
How can I Snippet in below code to the CMS page?
<script id="mediaTemplate" type="text/x-jsrender">
<div class="candid-wall-cell">
<div class="candid-wall-overlay">
</div>
<div class="candid-wall-overlay-text">
<i class="candid-icon candid-fa-{{> Media.Source.toLowerCase() }}"></i>
<div>SHOP NOW</div>
</div>
<a class='media' data-media-index='{{> Index }}'>
<img data-original="{{> Media.Images.LowResolution.Url }}"
alt="{{> Title }}"
style="display:inline-block;"
class="lazy">
</a>
</div>
</script>
<script type="text/javascript"
src="//api.getcandid.com/scripts/widget.js">
</script>
<script type="text/javascript">
candid.wall('#container', {
id: '111111111111111111111111111111111111',
cluster: 'prod-2',
layoutMode: 'masonry',
layout: 'standard'
});
</script>
<div id="container"></div>
Soluzione
It is best to try to add the script to a separate phtml file and include it in the CMS block. Create a file in your custom theme:
app/design/frontend/Custom/default/templates/scripts/myscript.phtml
Put your content in the file above (replace Custom with your theme)
On your CMS page, add this tag it include the script on the page
{{block class="Magento\Framework\View\Element\Template" template="scripts/myscript.phtml"}}
Good luck
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a magento.stackexchange