Vit*_*ito 7 plone archetypes zpt template-tal template-metal
我想只删除Plone标准内容类型(Document,Folder,blabla)的经典"描述字段"的"视图",因为我需要用结构化文本"结构化"该字段的文本,如:
This is my description<br/>
with many lines<br/>
bla bla<br/>
Run Code Online (Sandbox Code Playgroud)
更改呈现标准描述字段以将换行符转换为中断的模板并不难,但需要注意避免创建安全漏洞.
在主题产品或自定义文件夹中覆盖外观层kss_generic_macros.pt模板.
然后,您可以使用Products.PythonScripts.standard.newline_to_br将换行符转换为中断.您需要插入带有"结构"的转换后的文本,以防止中断转义.
由于你将使用"结构",你绝对必须在应用newline_to_br之前手动html转义描述(从标准使用html_quote),否则你将为XSS攻击创建一个向量.
修复宏的关键部分可能是:
<div metal:define-macro="description-field-view"
id="parent-fieldname-description"
tal:define="kss_class python:getKssClasses('description',
templateId='kss_generic_macros', macro='description-field-view');
pps modules/Products.PythonScripts.standard"
tal:condition="context/Description"
tal:attributes="class string:documentDescription$kss_class;">
<span metal:define-slot="inside"
tal:replace="structure python:pps.newline_to_br(pps.html_quote(context.Description()))">Description</span>
</div>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
878 次 |
| 最近记录: |