0

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>

1 Answer 1

1

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

2
  • Hi!, thanks for the reply, is there a folder in between default and template?
    – Paul Fan
    Nov 1, 2020 at 17:29
  • 1
    No, that is correct.
    – Kristoffer
    Nov 1, 2020 at 18:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.