I'm trying to include a very simple CSS and JavaScript snippet into a Modx page that lists MailChimp's latest newsletters:
<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 returns a document.write()
which outputs a linked list.
Unfortunately, TinyMCE seems to block the <style>
and <script>
tags, and this code is not added. What is the best way to add this code block to a specific page?
I found this page that shows ways to add code to the <head>
or <body>
tags, but I want the code to be inserted into a specific part of the page ( Because it executes document.write
, the position is important. p>
I was thinking another option would be to create a code snippet:
$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 doesn't seem to be the best approach.
P粉8418709422024-04-01 09:14:12
You can try wrapping the entire block in
tags.
sssccc
Another option is to go into the TinyMCS configuration file and add script
and style
to extended_valid_elements
. Something like this:
.AddSetting("extended_valid_elements", "script[*],style[*]")
Exactly how this is done (and whether it is possible) will depend on the TinyMCE plugin you use. Some plugins allow more configuration than others.
Another solution: (assuming the problem is that you want to have editable rich text content before and after the styles and script tags) --Add two rich text boxes to the page template with blocks containing your styles and Script tags them. For example, in a template you could have:
[[*content]] [[$chunkWithTags]] [[*anotherRichTextTV]]