Jump to:

23491 Posts in 18996 Topics by 2878 members

General Questions

SilverStripe Forums » General Questions » Where is valid_elements for TinyMCE in 2.3.1?

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Page: 1 2
Go to End
Author Topic: 5020 Views
  • PhilG
    Avatar
    Community Member
    2 Posts

    Where is valid_elements for TinyMCE in 2.3.1? Link to this post

    Need to try to allow some javascript functions to be put into the HTML view of TinyMCE without getting stripped out. Everything I am seeing is for older versions mainly changing the valid_elements located here:

    /cms/javascript/tinymce.template.js

    It is obviously different in 2.3.1

    Specifically, I am trying to do a simple url selector drop down with an OnChange that opens the selected url in a new window.

    Any help greatly appreciated!

    Phil

  • derralf
    Avatar
    Community Member
    24 Posts

    Re: Where is valid_elements for TinyMCE in 2.3.1? Link to this post

    Did you find the new settings file for TinyMCE?

    i also wanted to modify tinymce.template.js because site search doesn't work with special characters transformed to html entities.
    i need to change encoding to: entity_encoding : "raw"
    see: [url=http://www.silverstripe.org/form-questions/show/259551]http://www.silverstripe.org/form-questions/show/259551

    using SS 2.3.2 rc2

  • derralf
    Avatar
    Community Member
    24 Posts

    Re: Where is valid_elements for TinyMCE in 2.3.1? Link to this post

    allright i finally found it - you can now modify tinymce config in php

    look at:
    /sapphire/forms/HtmlEditorConfig.php

    and look at (was much more helpful for me):
    /cms//code/LeftAndMain.php
    there the settings for tiny in the main tab are put together, around line 158 and following

    now i simply put this in my _config.php:
    HtmlEditorConfig::get('cms')->setOptions(array('entity_encoding'=>'raw'));

  • vancouverWill
    Avatar
    Community Member
    121 Posts

    Re: Where is valid_elements for TinyMCE in 2.3.1? Link to this post

    Hi

    I have managed to change the valid elements in my /leftandmain.php file but when I tried to change the settings in my config.php file nothing was changing. I was changing the settings so I could put form elements in and then insert paypal buttons, I adjusted the equation the same way in both files but silverstripe only recognized the changes when they were made in leftandmain.php .

    Here is the code I used perhaps someone can see an error I missed?

    HtmlEditorConfig::get('cms')->setOption('valid_elements', '+form[method|action|target],+input[border|type|alt|name|src|value],+a[id|rel|rev|dir|tabindex|accesskey|type|name|href|target|title|class],-strong/-b[class],-em/-i[class],-strike[class],-u[class],#p[id|dir|class|align],-ol[class],-ul[class],-li[class],br,img[id|dir|longdesc|usemap|class|src|border|alt=|title|width|height|align],-sub[class],-sup[class],-blockquote[dir|class],-table[border=0|cellspacing|cellpadding|width|height|class|align|summary|dir|id|style],-tr[id|dir|class|rowspan|width|height|align|valign|bgcolor|background|bordercolor|style],tbody[id|class|style],thead[id|class|style],tfoot[id|class|style],-td[id|dir|class|colspan|rowspan|width|height|align|valign|scope|style],-th[id|dir|class|colspan|rowspan|width|height|align|valign|scope|style],caption[id|dir|class],-div[id|dir|class|align|style],-span[class|align],-pre[class|align],address[class|align],-h1[id|dir|class|align],-h2[id|dir|class|align],-h3[id|dir|class|align],-h4[id|dir|class|align],-h5[id|dir|class|align],-h6[id|dir|class|align],hr[class],dd[id|class|title|dir],dl[id|class|title|dir],dt[id|class|title|dir]');

    Thanks for any suggestions.

    Will

  • TotalNet
    Avatar
    Community Member
    181 Posts

    Re: Where is valid_elements for TinyMCE in 2.3.1? Link to this post

    Hi Will,

    I'm trying to get this working properly myself, I've read up on TinyMCE and tried to figure out what I can from the code.

    You might want to try extended_valid_elements instead of valid elements.

    I have a couple of sites deployed on SS2.3.0 and this used the old method, what I did find on this version was that SS has a callback function which strips out a whole bunch of other stuff (like all on* attributes!) regardless of how you configure TinyMCE, I have yet to find if this is being done in the latest implementation of TinyMCE on SS (although callback is deprecated in the latest version of TinyMCE)

    Let us know how you get on, I'll be taking another look at this soon.

    Cheers,

    Rich

    EDIT:
    Perhaps I should have taken a quick look at the code again before posting this. In SSv2.3.2 the cleanup callback function is still being used. As much as I hate to edit core files I will be removing 'cleanup_callback' => "sapphiremce_cleanup" from LeftAndMain and anywhere else I find it. unless I can override this in _config.php

    EDIT 2:
    Just noticed Will that you are using SetOption instead of setOptions

  • vancouverWill
    Avatar
    Community Member
    121 Posts

    Re: Where is valid_elements for TinyMCE in 2.3.1? Link to this post

    Hey

    Thanks for the quick reply. I tried both setoption with one element and setoptions with an array and no luck. I also tried the same with extended_valid_elements and none of these worked. You can see the methods I tried below. Anyway I still have it working by editing leftandmain.php but would be nice not to have to go into source files and be able to do it either from config.php or perhaps a class extension in the /code diterectory but not sure how this would be possible.

    HtmlEditorConfig::get('cms')->setOption('valid_elements', '+form[method|action|target],

    HtmlEditorConfig::get('cms')->setOptions(array('valid_elements' => "+form[method|action|target],

    HtmlEditorConfig::get('cms')->setOptions(array('extended_valid_elements' => "+form[method|action|target],

    HtmlEditorConfig::get('cms')->setOption('extended_valid_elements' , "+form[method|action|target],

    Cheers

    Will

  • steve_nyhof
    Avatar
    Community Member
    224 Posts

    Re: Where is valid_elements for TinyMCE in 2.3.1? Link to this post

    Did anyone ever get this figured out? I want to include an aweber.com form into my page, but it get stripped out. I have tried all what was mentioned already without success. Please help.

  • MattyJ
    Avatar
    Community Member
    11 Posts

    Re: Where is valid_elements for TinyMCE in 2.3.1? Link to this post

    After hours of longdesc being stripped out of HTML editor I found this line entered into mysite/_config.php to work in 2.3.7:

    HtmlEditorConfig::get('cms')->setOption('extended_valid_elements' ,"+img[id|dir|longdesc|usemap|class|src|border|alt=|title|width|height|align]");

    Hope this helps someone.

    5020 Views
Page: 1 2
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.