Jump to:

23486 Posts in 18995 Topics by 2878 members

General Questions

SilverStripe Forums » General Questions » HTML Source Editor stripping valid HTML tags (<acronym>, <dfn>,...)

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
Go to End
Author Topic: 3120 Views
  • cadabramarketing
    Avatar
    Community Member
    5 Posts

    HTML Source Editor stripping valid HTML tags (<acronym>, <dfn>,...) Link to this post

    I am trying to add markup such as <acronym> and <dfn> via the HTML Source Editor. These are valid, standard HTML phrase elements which are very helpful in making your content more meaningful.

    Same story with <span> attributes such as "lang": for example, markup such as

    <span lang="fr">bonjour</span>

    becomes

    <span>bonjour</span>

    after saving with "Insert"and reopening the text.

    In an identical editing sequence things work perfectly with more common tags - <div>s, <p>s etc., which are saved.

    Any idea what's happening here ? Is there any good reason why some tags are not allowed by SilverStripe's HTML Source Editor ?

    Thanks!

  • Willr
    Avatar
    Forum Moderator
    5508 Posts

    Re: HTML Source Editor stripping valid HTML tags (<acronym>, <dfn>,...) Link to this post

    Its todo with the configuration of TinyMCE within SS. You can set the elements which you allow. See http://doc.silverstripe.org/htmleditorconfig#customizing_allowed_html

  • cadabramarketing
    Avatar
    Community Member
    5 Posts

    Re: HTML Source Editor stripping valid HTML tags (<acronym>, <dfn>,...) Link to this post

    Thanks a lot, your prompt reply has been greatly appreciated.

    I followed your instructions, everything is OK now. Apologies, I should have checked the documentation in the first place...

    If you are the developer and the editor of the site (my case), this limitation might seem a little impractical at first. Once you consider the separation of these two roles, it makes perfect sense.

    Thanks again!

  • cadabramarketing
    Avatar
    Community Member
    5 Posts

    Re: HTML Source Editor stripping valid HTML tags (<acronym>, <dfn>,...) Link to this post

    I tried to disable the HTML Editor by putting the following code in mysite _config.php:

    HtmlEditorConfig::get('cms')->setOption('verify_html', 'false');

    But when I input code in the page via the editor, it acts erratically (for identical input the saved output varies during different attempts). In all cases the onsubmit/onreset options of the "<form>" tag get rejected. My code starts with

    <form id="contact" method="post" onsubmit="return validateForm()" onreset="clearMessages();" action="/fr/contact">

    after saving, it becomes

    <form id="contact" method="post" validateForm()" action="/fr/contact">

    Prior to attempting to disable HTML Editor I wanted to extend the valid elements by adding the following to the 'valid_elements' array via the HtmlEditorConfig::get('cms')->setOptions method:

    form[id|method|onsubmit|onreset|action],input[id|name|style|type],label[for],textarea[id|name|rows|style]

    in both _config.php files (mysite and cms) and had similar problems.

    Any idea what I might be doing wrong?

    I am using SS 2.4.0. Needless to say the field I am trying to edit is defined as HTMLText in my page class definition...

  • Mr Hanky
    Avatar
    Community Member
    2 Posts

    Re: HTML Source Editor stripping valid HTML tags (<acronym>, <dfn>,...) Link to this post

    I've got a problem where if I add a style to a <p> tag it vanishes when I update the page from the source editor.

    I think the documentation has changed since Willr's post. The link there goes to the Class: HtmlEditorConfig page, and I searched for 'element', 'attribute', 'custom' and 'allow' on the page and page source but couldn't find anything relevant there.

    I found a list of 'valid_elements' in HtmlEditorConfig::get('cms')->setOptions() (/cms/_config.php) - just trying to work out the significance of # and - before elements with lists of attributes in there.

    e.g.
    #p[id|dir|class|align|style]
    -h1[id|dir|class|align|style]

    Would love to RTFM but I'm struggling to find my way around it! Can anyone give me any pointers?

  • Mr Hanky
    Avatar
    Community Member
    2 Posts

    Re: HTML Source Editor stripping valid HTML tags (<acronym>, <dfn>,...) Link to this post

    My mistake it was an <img> tag that was losing the style, and adding 'style' after 'img' in the 'valid_elements' list I mentioned in my last post (in /cms/_config.php) sorted it out.

  • Invader_Zim
    Avatar
    Community Member
    141 Posts

    Re: HTML Source Editor stripping valid HTML tags (<acronym>, <dfn>,...) Link to this post

    Would love to RTFM but I'm struggling to find my way around it! Can anyone give me any pointers?

    Have a look at the tinymce documentation:
    http://tinymce.moxiecode.com/wiki.php/Configuration:valid_elements

    Cheers
    Christian

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