简体   繁体   English

Drupal 8 WYSIWYG数据以编程方式插入以显示纯HTML

[英]Drupal 8 WYSIWYG data programatically insertion make display plain html

I am working with some migration of content from one website to another. 我正在将内容从一个网站迁移到另一个网站。 I am doing this using a cron. 我正在使用cron执行此操作。

When I try to insert data to the WYSIWYG fields the data is inserted and showing in the WYSIWYG editor, but when I check this data in the front-end, the data seems to be pure HTML. 当我尝试将数据插入到WYSIWYG字段中时,数据将插入并显示在WYSIWYG编辑器中,但是当我在前端检查此数据时,该数据似乎是纯HTML。 Does anybody know what type of formatting I have to apply for proper insertion of data? 有人知道我必须申请哪种类型的格式化才能正确插入数据吗?

Finally I found the solution for this, 最后,我找到了解决方案,

I added the below code 我添加了以下代码

$node->set('field_textarea_data', ['format'=>'full_html','value'=>html_entity_decode($data->data,ENT_QUOTES, 'UTF-8')]);

And this solved my issue. 这解决了我的问题。

Thanks all for your response. 感谢大家的回应。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM