When I save a body element with glyphicons in it, it's displayed correctly. But when I edit the same field, Ckeditor seems to have removed it.

I added the following line to the advanced options, but to no avail: config.allowedContent = true;

How can I prevent this behaviour?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jcisio’s picture

Status: Active » Fixed

You can add new rules in the "Extra allowed content" section. E.g. i(glyphicon,glyphicon-*) to allow the i element with glyphicon classes.

knalstaaf’s picture

Status: Fixed » Active

Unfortunately this is not working.

I've tried the following in the Advanced content filter-tab (admin/config/content/ckeditor/edit/Full), and cleared the Drupal cache afterward:

i[glyphicon,glyphicon-*]
span[glyphicon,glyphicon-*]

I noticed the example on the Advanced content filter-tab uses square brackets. Round ones aren't working either btw.

And put this in the body of my page:

<i class="glyphicon glyphicon-envelope"></i>
<span class="glyphicon glyphicon-envelope"></span>

(Glyphicon would rather use a span tag, the i-tag is commonly used by Font Awesome.)

Both approaches aren't working though. They're being saved and displayed on the front, but when I return to the backend of that specific page, CKeditor removes these empty tags again. Putting an &nbsp; in between those tags isn't helping either.

Actually you can already test this by pasting the code in the body field, and switching from code view to design view, and back. You'll notice that these tags are cleared every time.

jcisio’s picture

fchandler’s picture

same here. Bootstrap 7.x-3.0 ckeditor 7.x-1.16

fchandler’s picture

I am having this, and other similar issues, with CKEditor and Bootstrap. I was trying to use the glyphicons with the code to make columns, collapsible content in the body field of a page. I have tried this straight out of the box as well as editing the profiles in CKEditor. I even turned off "Advanced content filter", yet CKeditor keeps stripping the glyphs and other parts of the html code. See attached. The CKEditorWithBootstrap1.txt shows the original html. The CKEditorWithBootstrap2.txt shows what all has been removed even after turning off "ACF". I also had disabled the "Correct faulty and chopped off HTML " in the Full HTML text under text formats (admin/config/content/formats/full_html). The html works fine when I disable CKEditor.

Drupal 7.39, CKeditor 7.x-1.16, Bootstrap 7.x-3.0

fchandler’s picture

Upon further investigation, I also had some css issues. I made a text format - fullHTML2 - with 'Correct faulty and chopped off HTML" turned off, and a profile in CKEditor using that text format and turning of AFC got things working.

denix’s picture

As far as I know CKEditor filter empty elements so you can try with