Jump to:

517 Posts in 247 Topics by 260 members

Content Editor Discussions

SilverStripe Forums » Content Editor Discussions » Tiny MCE Javascript Code Stripping Out.. Why?

Forum for content editors and CMS users.

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

Page: 1
Go to End
Author Topic: 6209 Views
  • Arun
    Avatar
    Community Member
    8 Posts

    Tiny MCE Javascript Code Stripping Out.. Why? Link to this post

    Hi,

    My name is Arun, I am new to the Silverstripe CMS. I have setup a site using this CMS. But now i am facing an issue that is regarding the tiny mce editor.

    The issue is that, while i am putting javascript code with in the editor, once we look after saving the content, we can see that the javascript code is fully stipped off.

    For eg:
    <script language="javascript">
    for(1=0;1<10;1++){
    document.write('helo world');
    }
    </script>

    consider if this is the code i have put with in the tiny mce editor, after saving it will look like
    <script language="javascript"></script>

    Anybody have idea why this happend...?

    Any help would be very much appreciated.

    Kind Regards,
    Arun.

  • banal
    Avatar
    Community Member
    901 Posts

    Re: Tiny MCE Javascript Code Stripping Out.. Why? Link to this post

    Hi Arun, welcome to SilverStripe

    There are several topics discussing this matter, just search the forum.
    These might give you some pointers:
    http://www.silverstripe.org/content-editor-discussions/show/270339
    http://silverstripe.org/general-questions/show/255947

    But if JavaScript in the Editor is your answer, then you're most likely asking the wrong question. Good practice would be to have an external JavaScript file that adds the desired functionality on top of the content. Have a look at jQuery.

  • Arun
    Avatar
    Community Member
    8 Posts

    Re: Tiny MCE Javascript Code Stripping Out.. Why? Link to this post

    Hello Banal,

    Nice to meet you.

    Thanks for your quick reply. You just save my life Banal. Now i can put javascript code with in the tiny mce editor.

    Thanks and Kind Regards,
    Arun.

  • tazzydemon
    Avatar
    Community Member
    120 Posts

    Re: Tiny MCE Javascript Code Stripping Out.. Why? Link to this post

    I did the silverstrip extended_valid_element mods and although the editor still left the script tags in, it removed the contents unless they were commented out.

    I have noticed that some people struggle with tinymce and this issue because tinymce are such purists. So, for those of you also wrangling over this please read the following from sourceforge:

    http://sourceforge.net/tracker/index.php?func=detail&aid=2847779&group_id=103281&atid=635682

    I used the information there telling me that the patches in minor version 2.6 were commented by WEBPOWER to retrofit the mods to the older tinymce.src in Silverstripe 2.3.4 (minor version 2.0.2)

    I personally do not like beong prevented from adding inline javascript however unethical it is. Placing it in the templates to be called is a pain. In this respect Modx is just the opposite and much easier to use. Why people (including tinymce in particular) get so precious about this I cannot imagine.

    The calls in your _config.php

    HtmlEditorConfig::get('cms')->setOption('extended_valid_elements', 'script[language|type|src]');
    HtmlEditorConfig::get('cms')->setOption('verify_html', 'false'); // turn off html validation

    Do not need to be made after this mod.

    Can we have FCKEDITOR for Silverstripe please!!!!???

    Julian

    Attached Files
  • banal
    Avatar
    Community Member
    901 Posts

    Re: Tiny MCE Javascript Code Stripping Out.. Why? Link to this post

    Well, I for one like an editor that
    a) creates valid xhtml
    b) does not allow my content editors to put in any garbage they find

    It's perfectly simple and good practice to add JavaScript as an unobtrusive layer on top of your html.
    If you really need some custom inline JavaScript, why not create a dedicated TextareaField for that? Where you can enter plain html without having to worry about any clean-up measures.

    Btw. Putting the JavaScript code in html-comments (<!-- -->) is perfectly valid.. this code will get executed anyway. So why not leave it that way?

  • tazzydemon
    Avatar
    Community Member
    120 Posts

    Re: Tiny MCE Javascript Code Stripping Out.. Why? Link to this post

    Dear Banal

    It only worked like that after I did the _config alterations specified and the comments were not quite right. The whole lot was suspicious.

    It not that I REALLY want inline JS it just that sometimes it is the easiest solution (say for a quick and dirty googlemap or whatever). I simply think the option should be allowed and not removed. The script is valid inline markup.

    I am trying Silverstripe from Modx which I have used a lot (and I live in Enzed). In modx creating the extra field is as easy as creating a template variable in the cms. In fact almost everything is done within the cms including the templates. This is its beauty (and its danger I suppose) Where modx fails is the multiple pass snippet parsing which can get slow (in V1).

    So, how does one create this extra field? Where are the docs. I love having extra fields.

    In modx I use a yaml template with several tinymce content fields. The system tests for their use and sets the columns up accordingly without the user even knowing about it. It would be nice to do that here.

    Julian

  • banal
    Avatar
    Community Member
    901 Posts

    Re: Tiny MCE Javascript Code Stripping Out.. Why? Link to this post

    I'm a former MODx user myself. But when I discovered SilverStripe, there was no going back for me. I'm not going to elaborate on the reasons why (who cares anyway).

    To add new fields to pages, you edit your Page-Class (add the fields to the $db array) or Subclasses thereof.
    All this stuff is basically covered in Tutorial 1 and 2, so you're probably best of starting there:
    http://doc.silverstripe.org/doku.php?id=tutorials

    6209 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.