I am trying to include a very simple snippet of CSS and JavaScript to a Modx page that lists recent newsletters from MailChimp:
<style type="text/css">
.display_archive {font-family: arial,verdana; font-size: 12px;}
.campaign {line-height: 125%; margin: 5px;}
</style>
<script language="javascript" src="//ZZZZ.us11.list-manage.com/generate-js/?u=XXXXX&fid=YYYYY&show=10" type="text/javascript"></script>
The <script> tag is returning a document.write() that outputs a list of links.
Unfortunately it looks like TinyMCE blocks <style> and <script> tags and this code is not being added. What is the best way to add this code chunk to a specific page?
I found this page that shows ways to add code to the <head> or <body> tags, but I am looking to insert the code on a specific part of the page (since it does document.write, the placement is important.
I was thinking an alternative is to create a snippet that does:
$response = file_get_contents('https://ZZZZZ.us11.list-manage.com/generate-js/?u=XXXXX&fid=YYYYY&show=10')
// remove "document.write"
// unescape slashes
return $clean_html;
But this does not seem like it would be the best method.
You can try wrapping your whole block in
<code></code>tags.Another option is to go into the TinyMCS config files and add
scriptandstyleto theextended_valid_elements. Something like:Exactly how it's done (and whether possible) will depend on which TinyMCE plugin you're using. Some plugins allow for more configuration than others.
Another solution: (assuming the problem is you want to have editable rich text content before AND after the style and script tags) -- add two rich text boxes to the page template with the chunk containing your style and script tags in between them. For instance in the template you could have: