我正在使用CKEditor并将内容保存到MySQL数据库。当尝试在编辑器中再次编辑内容时,HTML标记显示为文本,例如:
my test<br />and second line
我怎样才能让它再次正确地显示在编辑器中?
我已经摆弄htmlentities和html_entity_decode以及CKEditor相关设置一个多小时了,都无济于事。
$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);
3条答案
按热度按时间xdnvmnnf1#
看起来CodeIgniter的func
set_value()
在某些方面与htmlspecialchars()
类似。因此,如果您正在使用CKEditor,此变通方案可以帮助您。Change<any_tag> on CKEditor this workaround can help you. Change对此:
把html_entity_decode放在set_value的周围,原因很明显是set_value方法可能不使用$default_value参数,而是返回发布的数据。
pcww981p2#
对于使用CodeIgniter/CKEditor时可能遇到相同问题的用户:
解决此问题并仍使用CodeIgniter set_value()方法的方法如下:
请执行以下操作:
把html_entity_decode放在set_value的周围,原因很明显是set_value方法可能不使用$default_value参数,而是返回发布的数据。
谢谢你coramba让我意识到我的错误。
nbnkbykc3#
在Laravel中遇到此问题的任何人,
strip_tags
函数都很有帮助。{{ strip_tags($your_content) }}