gfo*_*ada 3 templates plone grok dexterity
我正在创建相当多的Dexterity内容类型(感谢zopeskel.dexterity devs !!)但是即使我需要它们是不同的内容类型(搜索,集合......),它们中的一些将被平等地呈现.
那么,有没有办法为不同的内容类型重用相同的模板?
好吧,我让它工作但我想知道这是否是正确的方法:
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")
Run Code Online (Sandbox Code Playgroud)
任何想法?如何跨内容类型重用模板?
为此创建一个接口:
from zope.interface import Interface
class ITwoColumnViewable(Interface):
"""Can be viewed in a 2-column layout"""
Run Code Online (Sandbox Code Playgroud)
然后,将此接口分配给各种内容类型,并直接为该类型注册该接口的视图:
class SameTwoColumnsView(TwoColumnsView):
grok.context(ITwoColumnViewable)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
222 次 |
| 最近记录: |