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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Customising the CMS /

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

HtmlEditorConfig with 'theme_advanced_disable' removes formatting after save and return


Go to End


2 Posts   2443 Views

Avatar
yurigoul

Community Member, 203 Posts

31 October 2009 at 6:49am

Edited: 31/10/2009 11:09am

Because I wanted to limit the number of options in TinyMCE and wanted to be sure all classes, styles etc are cleared on paste, I inserted the following in my function getCMSFields()

HtmlEditorConfig::get('cms')->setOptions(array('theme_advanced_disable' => 'underline, justifyleft, justifyright, justifycenter, justifyfull, indent, outdent, formatselect, styleselect, hr, pasteword, ssflash',
'invalid_elements' => '@[style | align | class]',
'valid_elements'=>'a, strong/ b, em/ i, p, br, ul, li, ol, table, td, tr, tf, th, tbody, thead, tfoot, s, img',
'entity_encoding', 'raw'));

After I give a ?flush=1 at first all the buttons I do not want have disappeared, and I can paste every style I want into it but instead of colored text, I get black text etc.

But: after for instance creating a list and then saving and then going to another page the first thing I notice is that all the buttons have returned. This might or might not happen, it depends, but do not know on what - sometimes you have to go back and forth several times. But if the buttons have returned and I go back to the page I edited, all my formatting is removed from the content field and the lists and tables have become one big paragraph (images remain).

Something else that happens most of the time in my browsers is this: If I login, the buttons I removed using my code are there, but if I give a ?flush=1 they go away and the script seems to function the way it should - until the formatting is removed.

I am testing this without the option to remove the buttons and so far it seems ok. Next I will test adding buttons to the simple theme.

I have tested this in Opera 9, Safari 4 and firefox 3.5.

I have attached the errorcodes Opera has given me (errors in LeftAndMain_right.js). If nobody finds any mistakes in my code, should I create a ticket out of it?

EDIT: errorcodes in opera seem to be unrelated to the HtmlEditorConfig, I have tried and failed to remove the text with the errorcodes

Attached Files
Avatar
yurigoul

Community Member, 203 Posts

31 October 2009 at 8:23am

Edited: 01/11/2009 1:19pm

tried HtmlEditorConfig::get('cms')->removeButtons() but it has the same result.

I have changed the FinalAndMain.php, same result here, or actually it got worse.

Realized the main problems are:
- removing buttons does not work well, it just works the first time you open one of the pages in the cms
- using 'valid_elements' causes the formatting to disappear, you never know when, but you can be certain it will at some point.
- using 'invalid_elements´ does not seem to work

EDIT: Made a ticket out of the mysteriously reappearing buttons problem, am waiting until someone can tell me what I did wrong with (in)valid_elements before I make a ticket out of that one.