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

Solved - Edit HTML Source - turn off validation


Reply


5 Posts   5390 Views

Avatar
BigChris

Community Member, 63 Posts

26 February 2010 at 5:22am

Edited: 21/03/2010 12:37am

Hi,

I am using SilverStripe v 2.3.6

I would like to be able to turn off or change the HTML Validation for the TinyMCE Edit HTML Source pop window on the Content.
Does anyone know how to do this?

So far I have entered html only to have it changed and not display properly on the front end.

To fix this I have changed the /cms/_config.php file from
'valid_elements' => "+a[id|rel|r......",
to
'valid_elements' => "*

  • ",

    This did not work.

    Nor did changing the value to be the Full XHTML rule set from
    http://wiki.moxiecode.com/index.php/TinyMCE:Configuration/valid_elements

    Also set the extended_valid_elements.

    I tried following this
    http://rationalogic.com/cms/silverstripe-tinymce-and-complex-html/

    I have also made changes to the /jsparty/tinymce2/tiny_mce.js

    This
    <img id="placeholder" src="images/galleryimage1.jpg" alt="image gallery" class="right" />
    becomes
    <p><img src="images/galleryimage1.jpg" alt="image gallery" class="right" /></p>

    I realise this is more a TinyMCE problem but if anyone can shed any light I'd be very very very grateful.

Avatar
BigChris

Community Member, 63 Posts

15 March 2010 at 11:05pm

I've tried various things to turn off the html validation. The reason for this is <p> tags are being inserted into the code and are not wanted nor necessary. This is in turn altering the source html for a page and screwing up the look of the page.

Now from what I have read this was configureable to turn off via Left and Main in previous versions. This appears to be configurable via mysite/_config.php but does not work in v2.3.6.

I added the following lines to _config.php
HtmlEditorConfig::get('cms')->setOption('verify_html', 'false'); // turn off html validation
HtmlEditorConfig::get('cms')->setOption('valid_elements', $longData);
HtmlEditorConfig::get('cms')->setOption('extended_valid_elements', $longData);

where $longData is the full tinymce list of valid html tags and their options.

The information contained here http://doc.silverstripe.org/doku.php?id=htmleditorconfig&amp;do=diff1246935937 does not appear to work for 2.3.6

I have looked at http://www.silverstripe.org/general-questions/show/268901 to no avail either.
same here http://silverstripe.org/general-questions/show/275085

This is getting desperate as I have been trying to solve this for 3 weeks and had no replies and I am all out of ideas.
So can the content editing for edit html source be set to not change the entered text?
and if so how is it set under v2.3.6

Avatar
banal

Community Member, 901 Posts

15 March 2010 at 11:13pm

I think it would be much easier if you would just style the <p> elements in a way, that they don't alter the look of your page? Eg. something like:

p { margin: 0; }

in your css...

Avatar
BigChris

Community Member, 63 Posts

16 March 2010 at 3:32am

Thanks Banal,

you are right that is the easiest way to do it. However its not just <p> tags it interferes with but id tags on images and various other valid html its stripping out.

Its giving me the fear.

Just a pity that each solution I have come across seams out of date. Probably have to rethink how I use the content area.

Cheers
Chris

Avatar
BigChris

Community Member, 63 Posts

21 March 2010 at 12:40am

This is now solved.

Turns out I was wrong about the permissions being added to mysite/_config. if you add the following it does work.
HtmlEditorConfig::get('cms')->setOption('verify_html', 'false'); // turn off html validation
HtmlEditorConfig::get('cms')->setOption('valid_elements', $longData);
HtmlEditorConfig::get('cms')->setOption('extended_valid_elements', $longData);

However it still put <p> around images and I had not realised the rest of it is working. I think it does this as on the tinymce the font style is set to paragraph.

However to get around it putting a <p> around the image and screwing up the layout I put in an empty div tag and this worked a charm. so <div></div> works great and its all going very well.

Thanks for your help on this.
Chris