Jump to:

5450 Posts in 1672 Topics by 1197 members

Customising the CMS

SilverStripe Forums » Customising the CMS » modifying tinymce to allow SOME users to use javascript

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

Page: 1
Go to End
Author Topic: 1388 Views
  • JohnHughes
    Avatar
    Community Member
    8 Posts

    modifying tinymce to allow SOME users to use javascript Link to this post

    I'm new to SS.

    I've got 2.4.1 installed.

    Two questions:

    1. Can I have different tinymce settings for different roles? (If yes, how is that accomplished?)

    2. What do I need to change in order to get tinymce to allow the following code:

    <a href="http://www.google.com/recaptcha/mailhide/d?k=01iEAR52Ac2Nww-Kte4m_RHQ==&amp;c=40xscf07XuDYgxvFJrVEdOiQ2jC_KyA2dbtJh-WOJIs=" onclick="window.open('http://www.google.com/recaptcha/mailhide/d?k\07501iEAR52Ac2Nww-Kte4m_RHQ\75\75\46c\07540xscf07XuDYgxvFJrVEdOiQ2jC_KyA2dbtJh-WOJIs\075', '', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=500,height=300'); return false;" title="Reveal this e-mail address">email me</a>

    The tinymce filter strips the onclick=window.open portion of the code.

    I've reviewed the instructions at doc.silverstripe.org/htmleditorconfig I would prefer not to turn off all validation.

  • banal
    Avatar
    Community Member
    901 Posts

    Re: modifying tinymce to allow SOME users to use javascript Link to this post

    Hi and welcome to SilverStripe

    1) I also tried this once. This thread might help you: http://ssorg.bigbird.silverstripe.com/general-questions/show/280243

    2) I strongly discourage from using any JavaScript in the WYSIWYG Editor. It doesn't belong there. And since these Scripts are invisible in the Editor, another person can easily remove them by accident.

    There are several ways around that issue though.
    A) Create a custom shortcode for popup-windows. The user can then enter the URL and the desired window-size. These docs can help you getting started with sortcodes: http://doc.silverstripe.org/shortcodes, http://ssbits.com/2-4-using-short-codes-to-embed-a-youtube-video/

    B) Use jQuery to open some links in a popup window. You could create a special CSS class (eg. "popup") in typography.css which you can then assign in the WYSWYG Editor. Load jQuery in your page and the following Script, and you're set:

    ;(function($) {
       $(function(){
          $("a.popup").click(function(event){
             event.preventDefault();
             window.open(
                $(this).attr("href"), "",
                "toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=500,height=300"
             );
             return false;
          });
       });
    })(jQuery);

    All links that have the "popup" class applied will then open in a popup.

    1388 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.