Kentico 自动修复 html 代码

Kentico automatically fixes html code

这看起来是个简单的问题,但我花了一个小时尝试修复它但没能成功。在我的 html(Editabletext webpart)中,我有类似 below:and Kentico 在所有情况下自动删除或修复我的 html 的东西:

<br /> [1]
<a href=""><p></p></a> [2]
<a href=""><div></div></a> [3]

在 [1] 中,Kentico 将 br 替换为   ;在 [2] & [3] 中,它移动了 p 和 div 中的 标签。现在,我明白我的代码没有遵循 [2] 和 [3] 中的标准,但对于这些特殊情况,我想 link 整个 div 或段落。如何关闭这种自动格式?

我在“设置”>“输出过滤器”下查看并为所有字段添加“/”(我指的是根目录及其下的所有内容),但它没有生效。谢谢!

Kentico 实际上不是更改 HTML 代码的人 - CKEditor is. CkEditor is a 3rd party WYSIWYG plugin that is used by Kentico for easy content editing and writing. The philosophy of CkEditor is to always output valid HTML code and modify it if necessary. There is no simple and realible way of changing this behaviour. It may be possible to disable the ACF as mentioned here 但强烈不建议他这样做。

相反,您应该考虑是否真的要使用可编辑文本 Web 部件。每次你需要完全控制 HTML 时,你应该避免使用 CkEditor 并使用其他东西代替(例如转换,将代码放入布局等)。

如果您需要将其作为 Web 部件或小部件,唯一的解决方案是使用 文本区域 表单控件创建您自己的小部件 Web 部件,然后您只需将其输出在 ASCX 控件中。 (或者您可以使用 Content beforeContent after 属性 每个 Web 部件都有 :-))