CKEditor在编辑器中显示HTML标签 [英] CKEditor displaying HTML tags in editor
问题描述
我使用CKEditor并将内容保存到MySQL数据库。当尝试在编辑器中再次编辑内容时,我得到HTML标签显示为文本,例如:
I am using a CKEditor and saving content to a MySQL database. When trying to edit the content again in the editor, I am getting HTML tags displayed as text, for example:
my test<br />and second line
如何在编辑器中正确显示?
How can I have it display in the editor correctly again?
我一直忙于htmlentities和html_entity_decode和CKEditor相关设置超过一个小时,没有效果。
I have been fiddling with htmlentities and html_entity_decode and CKEditor related settings for over an hour now, with no avail.
$config = array();
$config['enterMode'] = 2;
$config['shiftEnterMode'] = 1;
//$config['basicEntities'] = FALSE;
//$config['entities'] = FALSE;
//$config['entities_greek'] = FALSE;
//$config['entities_latin'] = FALSE;
//$config['htmlDecodeOutput'] = TRUE;
$ck_editor->editor("sec1_content", $default_value, $config);
推荐答案
CodeIgniter的func set_value()
以某种方式表现为 htmlspecialchars()
。所以如果你在CKEditor上得到< any_tag>这个解决方法可以帮助你。更改
It seems that CodeIgniter's func set_value()
acts like htmlspecialchars()
in some way. So if you are getting <any_tag> on CKEditor this workaround can help you. Change
$ck_editor->editor("sec1_content", set_value('sec1_content', html_entity_decode($default_value)), $config);
到此:
$ck_editor->editor("sec1_content", html_entity_decode(set_value('sec1_content', $default_value)), $config);
PoloRM
在set_value周围放置html_entity_decode。原因很明显是因为set_value方法可能不使用$ default_value参数,而是返回发布的数据。
PoloRM
Put html_entity_decode around set_value. The reason for this is obviously because the set_value method might not use the $default_value parameter but return the posted data instead.
这篇关于CKEditor在编辑器中显示HTML标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!