2

I want add script with reviews to custom_block in magento 2.

<span id="__ceneo-reviews-5404f405-e31c-4e74-9b51-0ebeee8bcd2d"></span>
<br/>
<small>
    <a href="https://www.ceneo.pl/26306-0a" rel="nofollow" target="_blank">&raquo; przeczytaj wszystkie opinie</a>
</small>

<script>
    (function (d,t){
    var g=d.createElement(t),s=d.getElementsByTagName(t)[0];
    g.src('https:'==document.location.protocol?'https://':'http://')+'ssl.ceneo.pl/shops/rw.js?accountGuid=5404f405-e31c-4e74-9b51-0ebeee8bcd2d';
    s.async=true;
    s.parentNode.insertBefore(g, s);
    }(document,'script'));
</script>

after save, I see only this content in html. enter image description here Looks .js do not work here. Any solution?

2

I hope, you may call that block in your custom phtml file right If so you can keep html element in cms block and keep JS snippet in your custom phtml file.

Something like below way,

<script type="text/javascript" xml="space">
    (function (d,t){var g=d.createElement(t),s=d.getElementsByTagName(t)[0];g.src=('https:'==document.location.protocol?'https://':'http://')+'ssl.ceneo.pl/shops/rw.js?accountGuid=5404f405-e31c-4e74-9b51-0ebeee8bcd2d';s.async=true;s.parentNode.insertBefore(g, s);}(document,'script'));
</script>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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