Jump to:

23459 Posts in 18906 Topics by 2877 members

General Questions

SilverStripe Forums » General Questions » Solved - Edit HTML Source - turn off validation

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: 5181 Views
  • BigChris
    Avatar
    Community Member
    63 Posts

    Solved - Edit HTML Source - turn off validation Link to this post

    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' => "*

  • BigChris
    Avatar
    Community Member
    63 Posts

    Re: Solved - Edit HTML Source - turn off validation Link to this post

    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

  • banal
    Avatar
    Community Member
    901 Posts

    Re: Solved - Edit HTML Source - turn off validation Link to this post

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

  • BigChris
    Avatar
    Community Member
    63 Posts

    Re: Solved - Edit HTML Source - turn off validation Link to this post

    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

  • BigChris
    Avatar
    Community Member
    63 Posts

    Re: Solved - Edit HTML Source - turn off validation Link to this post

    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

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