Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Umbraco how to stop Rich Text Box to automatically add <p> tag in html

I am developing a website in umbraco, the problem is when i insert my html in rich text editor it automatically inserts "p" (Paragraph Tag) tag in the html which is destroying my design.Please help me, i am stuck here.

Thank you.

like image 965
DevUsman Avatar asked Dec 13 '13 13:12

DevUsman


2 Answers

How are you adding the page field onto your markup? Through a view or as a pagefield?

If you're adding it as a pagefield add the attribute stripParagraph="true"

If you're adding in a view then you could try

Html.Raw(library.RemoveParagraphTags(Model.bodyText.ToString()))

But that will only remove the first one

You could roll your own version of that method to remove all P tage, or try what's suggested here - http://scottsdevblog.com/2011/08/get-rid-of-those-pesky-p-tags-in-umbracos-tinymce-editor/

like image 194
Carl Sargunar Avatar answered Sep 19 '22 16:09

Carl Sargunar


The OP asked how to stop the paragraph tags from being inserted. All of the proposed answers fail to prevent the insertion; they just try to mitigate its existence.

In your \config\tinyMceConfig.config, set forced_root_block to false.

<customConfig> ... <config key="force_p_newlines">false</config> <config key="forced_root_block">false</config> ... </customConfig>

like image 38
LeeC Avatar answered Sep 19 '22 16:09

LeeC