Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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?
Comment | File | Size | Author |
---|---|---|---|
#5 | CKEditorWithBootstrap2.txt | 3.53 KB | fchandler |
#5 | CKEditorWithBootstrap1.txt | 4.99 KB | fchandler |
Comments
Comment #1
jcisio CreditAttribution: jcisio commentedYou can add new rules in the "Extra allowed content" section. E.g.
i(glyphicon,glyphicon-*)
to allow the i element with glyphicon classes.Comment #2
knalstaaf CreditAttribution: knalstaaf commentedUnfortunately 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 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:
(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
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.
Comment #3
jcisio CreditAttribution: jcisio commented#1908696: When using Font-Awesome, prevent CKEditor 4.x from removing <i></i>
Comment #4
fchandler CreditAttribution: fchandler commentedsame here. Bootstrap 7.x-3.0 ckeditor 7.x-1.16
Comment #5
fchandler CreditAttribution: fchandler commentedI 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
Comment #6
fchandler CreditAttribution: fchandler commentedUpon 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.
Comment #7
denix CreditAttribution: denix as a volunteer commentedAs far as I know CKEditor filter empty elements so you can try with