我正在开发自定义 Dexterity 内容类型的列表页面,我想提取其中一张图像以显示在列表中,就像充满新闻项目的文件夹的列表页面显示的方式一样标题和说明旁边的缩略图(即folder_summary_view)。
解决这个问题的最佳方法是什么?我尝试自定义folder_summary_view模板来更改缩略图代码以查找'item_object/thumbnail'
,但它返回错误,因为它是blob图像或其他内容:
<a href="#" tal:condition="exists:item_object/thumbnail" tal:attributes="href python:test(item_type in use_view_action, item_url+'/view', item_url)">
<img src="" alt="" tal:replace="structure python: path('nocall:item_object/thumbnail')(scale='original', css_class='tileImage')" />
</a>
返回:
Module Products.PageTemplates.ZRPythonExpr, line 48, in __call__
__traceback_info__: path('nocall:item_object/thumbnail')(scale='original', css_class='tileImage')
Module PythonExpr, line 1, in <expression>
TypeError: 'NamedBlobImage' object is not callable
我想我也有兴趣了解如何调用任何其他字段。它会自动提取标题和描述。有没有一种简单的方法来调用沼泽地?即,如果有一个名为:developer_name
的文本字段 - 我将如何在文件夹摘要 View 中的标题后面显示该文本字段?
我看到了this question如果有帮助,但它似乎与迁移和不显示内容更相关。
最佳答案
仍然需要为 Plone 的默认新闻项目更新folder_summary_view,如下所示(适用于两者;Plone 的默认 Archetype- 和 Dexterity-newsitem):
<a href="#"
tal:condition="exists:item_object/@@images/image"
tal:attributes="href python:test(item_type in use_view_action, item_url+'/view', item_url)">
<img src="" alt=""
tal:replace="structure item_object/@@images/image/mini" />
</a>
其中“image”是字段名称,以防您的名称不同。
参见 plone.app.imaging 的 README供完整引用。
我希望尽快找到时间来完成这项工作,除非其他人也要做这件事;)
注意:我想我记得不建议使用 python:test()
,也许这部分也应该调整。
对于一般渲染您的字段,您可以使用很好的ol':
<div tal:content="structure context/developer_name" />
使用 TTW 创建的 Dexterity-CT 和文本字段进行测试。
另请参阅(带有一个令人理解的示例): http://developer.plone.org/reference_manuals/external/plone.app.dexterity/custom-views.html#simple-views
关于plone - 将 "news item"样式缩略图添加到 Dexterity 内容类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22720038/