Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Content Editor Discussions /

Forum for content editors and CMS users.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Tiny MCE Code Strip 2.3.3


Reply


3 Posts   3516 Views

Avatar
3 midgets In a man suit

Community Member, 13 Posts

6 October 2009 at 5:47am

Hello,

I am having an issue, or should I say have been having an issue with silverstripe not letting me put any kind of code into the individual pages.

I need to have the ability to do some basic javascript and other things on individual pages such as set parameters etc. on flash files but it strips everything
<a href="#"
   onmouseover="changeImages('checkbutton_01', 'images/checkbutton_01-over.gif'); return true;"
   onmouseout="changeImages('checkbutton_01', 'images/checkbutton_01.gif'); return true;"
   onmousedown="changeImages('checkbutton_01', 'images/checkbutton_01-over.gif'); return true;"
   onmouseup="changeImages('checkbutton_01', 'images/checkbutton_01-over.gif'); return true;">
   <img name="checkbutton_01" src="images/checkbutton_01.gif" width="219" height="81" border="0" alt=""></a>

I would also like to be able to do includes at the editing level e.g.
<% include packages %>

any help would be greatly appreciated

Avatar
dalesaurus

Community Member, 283 Posts

14 October 2009 at 4:30am

Generally you should be adding custom javascript via a template or using a separate file that gets included.

However if you are certain you want to be using TinyMCE to input javascript you'll have to set some options to stop it from stripping elements. The editor in the CMS is controlled via PHP calls in your _config.php file:

http://doc.silverstripe.com/doku.php?id=htmleditorconfig#setting_tinymce_options_eg_valid_elements

For Javascript you'll want to add something like this to extended_valid_elements

script[language|type|src]

There are many more options you can work with, see the TinyMCE docs:
http://wiki.moxiecode.com/index.php/TinyMCE:Configuration/valid_elements

You might want to be very thorough and set invalid_elements to nothing.

PS. This is a pretty common question, it is covered in many topics you can find via the Search. If you get this to work to your satisfaction please let us know in here and I will be sure to add it to the wiki.

Avatar
Chip Designs

Community Member, 15 Posts

16 April 2010 at 10:29pm

Edited: 16/04/2010 10:30pm

Hi Dalesaurus,

I'm, using SS 2.3.7 - Adding script[language|type|src] to the extended_valid_elements found in cms\_config.php seemed to do the trick for me.

Cheers,
Rob