【发布时间】:2012-04-25 10:07:18
【问题描述】:
我有一个包含标准 ATImages 的 Dexterity 文件夹类型。我希望它在文件夹或集合摘要视图中列出时显示其包含的第一个图像。我尝试在视图上设置图像属性,但当我尝试访问其 URL 时甚至没有咨询:http://site/my-dex/image
这是我使用的代码:
class View(grok.View):
grok.context(IMyDex)
grok.require('zope2.View')
@memoize
def photos(self):
"""Return a catalog search result of photos to show
"""
context = aq_inner(self.context)
catalog = getToolByName(context, 'portal_catalog')
folder_path = '/'.join(context.getPhysicalPath())
results = catalog(path=folder_path,
portal_type='Image',
sort_on='getObjPositionInParent')
return results
@property
def image(self):
try:
first_img = self.photos[0].getObject()
except IndexError:
first_img = None
return first_img
我应该怎么做?
【问题讨论】:
-
也许你可以展示你的模板代码?
-
不是问题,但我看不出它有什么帮助,因为我想要为我的类型显示一个规范图像,以便它显示在 Plone 的默认文件夹摘要视图中,例如新闻项目。
标签: image plone listings dexterity