1
votes

I am using ckeditor to insert some html structure into db. I firstly use code view to paste html structure into editor, after inserting into mysql db, until echo at webpage, the html structure data are still maintained.

However, when the same data is called into the same ckeditor again for updating, the structure is destroyed, and I found the ckeditor has automatically changed html tags to the codes, below is an extract:-

A) html code to be pasted to editor code view for inserting (good)

<a href="#">
<img src="../catalog/view/theme/default/images/services/b1.jpg" alt="" />
<div class="btn-gradient-yellow">Details
<div class="btn-arrow"></div>
</div>
<div class="cat-title-bg">
SERVICES
</div>
</a>

B) db data (good)

<a href="#">
<img src="../catalog/view/theme/default/images/services/b1.jpg" alt="" />
<div class="btn-gradient-yellow">Details
<div class="btn-arrow"></div>
</div>
<div class="cat-title-bg">
SERVICES
</div>
</a>

C) webpage data called from db (good)

called by html_entity_decode($record["content"],ENT_COMPAT, 'UTF-8');

<a href="#">
<img src="/catalog/view/theme/default/images/services/b1.jpg" alt="" />
<div class="btn-gradient-yellow">Details
<div class="btn-arrow"></div>
</div>
<div class="cat-title-bg">
SERVICES
</div>
</a>

D) code view in ckeditor, with contents filled from the above data (changed)

called by html_entity_decode($record["content"],ENT_COMPAT, 'UTF-8');

<a href="#"><img alt="" src="../catalog/view/theme/default/images/services/b1.jpg" /></a>

<div class="btn-gradient-yellow"><a href="#">Details </a>

<div class="btn-arrow">&nbsp;</div>
<a href="#"> </a></div>
<a href="#"> </a>

<div class="cat-title-bg"><a href="#">SERVICES</a></div>

How can I ask ckeditor not to add changes to the data?

1

1 Answers

1
votes

CKEditor modifies your HTML because it is incorrect. You cannot put block elements inside of <a> unless you use HTML5 which isn't supported by CKEditor yet.

See my answer for related question. Also take a look at this one regarding blocks in <a>.