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.

General Questions /

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

Where is valid_elements for TinyMCE in 2.3.1?


Go to End
Reply


11 Posts   5352 Views

Avatar
PhilG

Community Member, 2 Posts

3 June 2009 at 6:42am

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

Avatar
derralf

Community Member, 24 Posts

16 June 2009 at 6:15am

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[/url]

using SS 2.3.2 rc2

Avatar
derralf

Community Member, 24 Posts

16 June 2009 at 11:09pm

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'));

Avatar
vancouverWill

Community Member, 121 Posts

4 August 2009 at 4:31am

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

Avatar
TotalNet

Community Member, 181 Posts

4 August 2009 at 9:45am

Edited: 04/08/2009 10:01am

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

Avatar
vancouverWill

Community Member, 121 Posts

7 August 2009 at 9:44am

Edited: 07/08/2009 9:44am

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

Avatar
steve_nyhof

Community Member, 224 Posts

29 October 2009 at 3:07am

Edited: 29/10/2009 3:07am

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.

Avatar
MattyJ

Community Member, 11 Posts

19 May 2010 at 12:19am

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.

Go to Top