3

I have a problem when trying to put a div into a content of an entry.

I'm creating entries, building a HTML hierarchy that helps me to manipulate the content with JS. I'm adding divs an build something like this:

<div id="cont1" class="content" >
  <h3>Hi I am a title</h3>
  <p>this is the introduction </p>
  <p>this is the content</p>
</div>

When I create this, the hierarchy is right, but when I edit it from the CP, all the divs change to this:

<p id="cont1" class="content" ></p>
<h3>Hi I am a title</h3>
<p>this is the introduction </p>
<p>this is the content</p>

What can I do to prevent this from happening? Hope you can help me, thanks.

0

1 Answer 1

6

Assuming you are using the Rich Text field, you'll want to look at the Redactor setting, convertDivs.

convertDivs (Default setting is true)

With this option turned on, Redactor will automatically replace divs to paragraphs.

Go in to your field settings: Craft Admin › Settings › Fields › Rich Text field name

Look at the config settings to determine which config file you are using. Then, go in to your craft/config/redactor/ConfigFile.json file and edit your redactor settings to exclude the convertDivs setting (assuming nothing else in your config file):

{
    convertDivs: false
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.