Templates 对不同的内容类型重复使用相同的模板
我正在创建相当多的灵巧内容类型(感谢devs!!),但即使我需要它们是不同的内容类型(搜索、集合…),它们中的一些将被同等地呈现 那么,有没有办法为不同的内容类型重用相同的模板 好的,我成功了,但我想知道这是否是正确的方法:Templates 对不同的内容类型重复使用相同的模板,templates,plone,grok,dexterity,Templates,Plone,Grok,Dexterity,我正在创建相当多的灵巧内容类型(感谢devs!!),但即使我需要它们是不同的内容类型(搜索、集合…),它们中的一些将被同等地呈现 那么,有没有办法为不同的内容类型重用相同的模板 好的,我成功了,但我想知道这是否是正确的方法: from my.product.parent_type import IParentType, ParentType, TwoColumnsView ... code omitted ... # Common folder for templates grok.temp
from my.product.parent_type import IParentType, ParentType, TwoColumnsView
... code omitted ...
# Common folder for templates
grok.templatedir('parent_type_templates')
class SameTwoColumnsView(TwoColumnsView):
grok.context(CustomClass)
grok.require('zope2.View')
grok.template("twocolumnsview")
有什么想法吗如何跨内容类型重用模板?为此创建一个界面:
from zope.interface import Interface
class ITwoColumnViewable(Interface):
"""Can be viewed in a 2-column layout"""
然后将此接口分配给各种内容类型,并注册该接口的视图,而不是直接注册类型:
class SameTwoColumnsView(TwoColumnsView):
grok.context(ITwoColumnViewable)