提供与模式设置关联的模板视图。
项目描述
简介
此软件包允许您定义一组视图、模式模板,这些模板可以用作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 的散列
算法 | 散列摘要 | |
---|---|---|
SHA256 | 75856aa828eaf56f340e7f1cafff2119e9315cd56d09a04a2d8f1dadea165b70 |
|
MD5 | 4f0b7421280a11c2a6edcf86fad34bd8 |
|
BLAKE2b-256 | 2105dc3f6ac7292dca96a80b2f0fc5448a2d57e56f5cc3bac858a191553ba60e |