在portlet中渲染内容提供者
项目描述
简介
collective.portlet.contentprovider 允许您将内容提供者(如viewletmanagers)放入portlet中。此工具旨在供经验丰富的主题开发者使用,因为实际使用将需要重新配置ZCML和Generic Setup配置文件中viewlets和viewlet managers的能力。
安装类似于Plone插件。将collective.portlet.contentprovider添加到您的buildout中的eggs列表。如果使用plone的早期版本,也请将其添加到zcml slugs中。
使用collective.portlet.contentprovider
使用示例最好通过实际用例来展示:将Products.Carousel幻灯片添加到portlet中。通常,Carousel将其横幅viewlet(Products.Carousel.viewlet)添加到IContentViews viewletmanager中。假设我们希望将其显示在collective.portlet.contentprovider portlet中。
viewlets不是作为直接内容提供者使用的(它们需要一个管理器),因此我们需要告诉内容提供者portlet显示一个显示Products.Carousel.viewlet的viewletmanager。因此,我们只需添加一个内容提供者portlet,并告诉它(在portlet编辑器的提供者字段中)显示plone.contentviews。这可以工作,但它也会引入由plone.contentviews处理的所有其他内容。
因此,为了正确完成这项任务,我们需要执行典型的viewlet舞蹈,将viewlets从一个管理器移动到另一个管理器。我们还将利用collective.portlet.contentprovider注册了一个在别处未使用的viewlet manager这一事实。因此,在我们的主题产品配置文件configure.zcml中,我们只需设置该管理器来处理carousel即可。
<browser:viewlet name="Products.Carousel.pviewlet" for="*" manager="collective.portlet.contentprovider.interfaces.IContentProviderPortlet" class="Products.Carousel.browser.viewlet.CarouselViewlet" permission="zope2.View" layer=".interfaces.IThemeSpecific" />
在我们的viewlets.xml配置文件中,隐藏旧管理器中的轮播视图。
<hidden manager="plone.contentviews" skinname="plonetheme.ucdvaw"> <viewlet name="Products.Carousel.viewlet"/> </hidden>
最后,只需添加一个contentprovider端口组件,并告诉它显示collective.portlet.contentprovider_vmanager。
变更日志
1.1
修复初始版本中缺失的文件
1.0
初始版本