plone - 如何更改 portlet 顺序(先放置父 portlet)

标签 plone

我如何重新排序 portlet,以便继承的父 portlet 排在当前项的 portlet 之前?

最佳答案

Mathias 的解决方案似乎更简单;无论如何,如果您不想安装第三方产品,我想保留此文档。

您只需编写适配器即可更改 portlet 的排序方式。例如,下面的一个在提供 IATImage 接口(interface)(图像)的任何对象上重新排序 portlet,以便首先呈现内容类型 portel,然后是组 portel,最后是上下文 portel:

from plone.portlets.interfaces import IPortletManager
from plone.portlets.interfaces import IPortletRetriever
from plone.portlets.retriever import PortletRetriever as BaseRetriever
from Products.ATContentTypes.interfaces import IATImage
from zope.component import adapts
from zope.interface import implements


class PortletRetriever(BaseRetriever):
    implements(IPortletRetriever)
    adapts(IATImage, IPortletManager)

    def getPortlets(self):
        assignments = super(PortletRetriever, self).getPortlets()
        context = [p for p in assignments if p['category'] == 'context']
        group = [p for p in assignments if p['category'] == 'group']
        content_type = [p for p in assignments if p['category'] == 'content_type']
        new_assignments = content_type + group + context
        return new_assignments

不要忘记在您的 ZCML 文件中使用以下内容注册您的适配器:

<configure xmlns="http://namespaces.zope.org/zope">
  ...
  <adapter factory=".adapters.PortletRetriever" />
  ...
</configure>

关于plone - 如何更改 portlet 顺序(先放置父 portlet),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28757252/

相关文章:

Plone:如何检查用户是何时创建的以及由谁创建的?

python - 在以灵活的形式设置另一个字段后,动态更改一个字段的下拉选项。架构

plone - Zope 3 浏览器能否覆盖 CMF 皮肤中的模板 :page?

plone - 如何在Plone的查看页面中隐藏经过身份验证的用户的作者信息(署名)?

selenium - 为功能性 Plone 测试用例记录 Selenium 测试

plone - 全文搜索各种外部格式 plone 4.2

windows - 在 Windows 上运行 zopeskel 后缺少本地命令

oauth-2.0 - 使用 OAuth2 在 Plone 站点上创建第三方 API?

plone - 显示具有特定标题的自定义 Dexterity 内容类型的集合

forms - 如何修改updateWidgets中的z3c表单字段?