跳转到主要内容

提供与模式设置关联的模板视图。

项目描述

简介

此软件包允许您定义一组视图、模式模板,这些模板可以用作Plone站点视图的模板。

所以基本上,它只允许一个简单的机制来提供附加的可重复使用的模板,并附加了设置。您为每个设置填写模板的模板,然后可以从站点其他地方的另一个模板视图中引用它。

基本示例

定义您的设置

>>> class ICustomSettings(Interface):
>>>     setting_one = schema.TextLine(title=u'Setting One')
>>>     setting_two = schema.Text(title=u'Setting Two', default=u'')

定义模板视图实用工具

>>> from wildcard.templatedviews.browser import BaseViewUtility
>>> from plone.app.form.widgets.wysiwygwidget import WYSIWYGWidget
>>> class CustomTemplateViewUtility(BaseViewUtility):
>>>     settings = ICustomSettings
>>>     _for = None
>>>     title = u'Custom Template'
>>>     description = u'a custom template settings.'
>>>     custom_widgets = (
>>>         ('setting_one', WYSIWYGWidget),
>>>     )

并使用zcml连接

>>> <browser:page
>>>   for="*"
>>>   name="custom-template"
>>>   class="wildcard.templatedviews.browser.BaseView"
>>>   template="templates/custom-template.pt"
>>>   permission="zope2.View"
>>> />
>>> <utility factory=".CustomTemplateViewUtility" name="custom-template" />
>>> <adapter
>>>   for="*"
>>>   provides=".ICustomSettings"
>>>   factory="wildcard.templatedviews.settings.TemplateViewSettings"
>>> />

然后在您的 custom-template.pt 中,您可以使用设置如下所示

>>> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"
>>>       xmlns:tal="http://xml.zope.org/namespaces/tal"
>>>       xmlns:metal="http://xml.zope.org/namespaces/metal"
>>>       xmlns:i18n="http://xml.zope.org/namespaces/i18n"
>>>       lang="en"
>>>       metal:use-macro="here/main_template/macros/master"
>>>       i18n:domain="plone">
>>> <body>
>>>
>>> <metal:main fill-slot="main" tal:define="settings python: view.settings">
>>>   <tal:main-macro metal:define-macro="main">
>>>     <h1 tal:content="python: settings.setting_one" />
>>>     <p tal:content="structure python: settings.setting_two" />
>>>   </tal:main-macro>
>>> </metal:main>
>>> </body>
>>> </html>

您还需要将“templated-view”视图添加到您想要使用的内容类型可用的视图列表中。

现在在安装后使用它,从显示下拉菜单中选择“templated-view”,然后使用“选择模板”和“模板设置”来自定义您的模板视图。

查看源代码以获取更多使用示例。

变更日志

1.0b4 (2012-08-27)

  • 修复transform的使用

1.0b3 (2012-08-09)

  • plone 4.1 兼容

  • 转换uids

1.0b2 (2011-10-25)

  • 如果对象遍历不起作用,请尝试在重定向存储中查找它

1.0b1 (2011-04-13)

  • 为设置和所选模板提供保存事件

  • 允许字段排序

1.0a2 (2010-04-10)

  • 修复找不到实用工具的问题

  • 添加更多视图实用工具方法

1.0a1 (2011-03-20)

  • 初始发布

项目详情


下载文件

下载适合您平台的文件。如果您不确定选择哪个,请了解有关安装包的更多信息。

源代码分发

wildcard.templatedviews-1.0b4.zip (27.5 kB 查看散列)

上传时间

由以下支持

AWS AWS 云计算和安全赞助商 Datadog Datadog 监控 Fastly Fastly CDN Google Google 下载分析 Microsoft Microsoft PSF 赞助商 Pingdom Pingdom 监控 Sentry Sentry 错误日志 StatusPage StatusPage 状态页面