We have a client that want to embed <script> code in the CMS for his social media curator accounts which is fine but I cant get it to render as HTML , it just shows the code rather than rendering. Anyone got any ideas please?
- /* curator-feed */
- var i, e, d = document, s = "script";i = d.createElement("script");i.async = 1;
- i.src = "https://cdn.curator.io/published/b54c3375-7ee1-41e3-8522-d3c1b6cf935a.js";
- e = d.getElementsByTagName(s);e.parentNode.insertBefore(i, e);
see https://stackoverflow.com/a/24614829/2812842 (edited)
I am running tinyMCE on my site and I'm trying to insert script tags. I am trying to insert my script tags into the body of the source of the tinyMCE instance. However, when I do I get problems. ...
here's an example for how to enable it in SS: https://github.com/silverstripe/silverstripe-admin/blob/1/_config.php#L34 (edited)
'extended_valid_elements' => "img[class|src|alt|title|hspace|vspace|width|height|align|name"
you'd be better to add a
CuratorURL textfield to your page, allow them to put
https://cdn.curator.io/published/b54c3375-7ee1-41e3-8522-d3c1b6cf935a.js into it, then render the rest of the script tag in a template and insert the URL
FYI we do something similar to this with an A/B tester tool on http://silverstripe.org, TextField in the CMS for the URL and insert the rest of the script tag in a template if it's set. also common with google analytics tracking code - enter your code and then render the rest of the snippet in a template if it's set