Problems, need help? Have a tip or advice? Post it here.
2 posts Page 1 of 1
I am building a web site for a non-techy friend using Couch. I only want them to be able to edit the text. Pretty simple.

I place Couch code after my CSS class with my formatting.

<p class="paragraph paragraph-feature"><cms:editable name='relationshipcoachtxt' type='richtext'>text that lost its formatting is here.</cms:editable></p>

Open Couch, edit text, save and refresh my web page and 100% of the formatting in class="paragraph paragraph-feature" is gone.

I do not understand why all of my CSS text formatting is lost. Now I notice when I go into the HTML and remove the P tag and publish the formatting is restored but I've made six text boxes available for my friend to edit and she's not savvy enough to remove p tags each time she publishes and shouldn't have to.

From what I've read so far I can use custom_styles where I can edit JSON files to create custom drop downs re-defining styles I've already defined. This seems like a pain to do and I tried unsuccessfully to implement tonight.

excerptHTML - removes all P tags and everything in-between so that didn't work either.

I don't understand why something as simple as a text editor has to be so complicated in 2020.

Any ideas?

Dustin
Hi,

You are trying to output contents within a parent <P> block -
Code: Select all
<p class="paragraph paragraph-feature">
    ...
</p>

Now, as you of course know, <P> does not permit any other block element as it child and will automatically close if it encounters one. That is what is causing the formatting to break when CKeditor decides to output its own <P>s.

So, if you absolutely must use the existing <P> as the parent block, then using CKEditor for its content will not work (as almost every element it outputs will be a block element).

You should use a simple type 'textarea' instead.
Enclose its output within <cms:nl2br> as follows and the client can break the text into multiple blocks using newline -
Code: Select all
<p class="paragraph paragraph-feature">
    <cms:nl2br><cms:show region_name /></cms:nl2br>
</p>

Hope this helps.
2 posts Page 1 of 1