Jump to:

5537 Posts in 1737 Topics by 1223 members

Customising the CMS

SilverStripe Forums » Customising the CMS » HtmlEditorConfig with 'theme_advanced_disable' removes formatting after save and return

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

Page: 1
Go to End
Author Topic: 1615 Views
  • yurigoul
    Community Member
    202 Posts

    HtmlEditorConfig with 'theme_advanced_disable' removes formatting after save and return Link to this post

    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
  • yurigoul
    Community Member
    202 Posts

    Re: HtmlEditorConfig with 'theme_advanced_disable' removes formatting after save and return Link to this post

    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.

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.