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

HTML Source Editor stripping valid HTML tags (<acronym>, <dfn>,...)


Reply


7 Posts   3334 Views

Avatar
cadabramarketing

Community Member, 5 Posts

11 June 2010 at 10:58am

Edited: 11/06/2010 11:00am

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!

Avatar
Willr

Forum Moderator, 5513 Posts

11 June 2010 at 12:37pm

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

Avatar
cadabramarketing

Community Member, 5 Posts

11 June 2010 at 9:10pm

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!

Avatar
cadabramarketing

Community Member, 5 Posts

15 June 2010 at 4:56am

Edited: 17/06/2010 10:46am

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

Avatar
Mr Hanky

Community Member, 2 Posts

19 February 2011 at 12:25am

Edited: 19/02/2011 12:39am

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?

Avatar
Mr Hanky

Community Member, 2 Posts

19 February 2011 at 12:38am

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.

Avatar
Invader_Zim

Community Member, 141 Posts

19 February 2011 at 3:01am

Edited: 19/02/2011 3:01am

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:
[url]http://tinymce.moxiecode.com/wiki.php/Configuration:valid_elements[/url]

Cheers
Christian