7
在Plone 4.1中禁用Portlet類型站點範圍內的最佳方式是什麼?默認設置提供〜10個portlet類型,但站點用戶只有很少的用例(靜態文本,新聞)。禁用Plone中站點範圍內的portlet類型
在Plone 4.1中禁用Portlet類型站點範圍內的最佳方式是什麼?默認設置提供〜10個portlet類型,但站點用戶只有很少的用例(靜態文本,新聞)。禁用Plone中站點範圍內的portlet類型
Portlets註冊爲工具,與zope組件機器的IPortletType
接口。這些註冊是在使用portlets.xml註冊portlet時爲您生成的。然後,Portlet管理UI使用這些實用程序註冊來枚舉可添加的Portlet。
幸運的是,plone.portlets.utils
提供了一個方便的API來再次註銷這些portlet:
def unregisterPortletType(site, addview):
"""Unregister a portlet type.
site is the local site where the registration was made. The addview
should is used to uniquely identify the portlet.
"""
的addview
參數是一個字符串,並且是相同的如在portlet.xml中註冊中使用。例如,日曆Portlet註冊爲:
<portlet
addview="portlets.Calendar"
title="Calendar portlet"
description="A portlet which can render a calendar."
i18n:attributes="title;
description"
>
<for interface="plone.app.portlets.interfaces.IColumn" />
<for interface="plone.app.portlets.interfaces.IDashboard" />
</portlet>
您可以從您的網站通過運行下面的代碼片段從而刪除日曆Portlet:
from plone.portlets.utils import unregisterPortletType
unregisterPortletType(site, 'portlets.Calendar')
您也可以只使用GenericSetup的portlet。 XML文件中的設置時間刪除門戶,只列出了門戶addview
參數和remove
屬性添加到元素:
<?xml version="1.0"?>
<portlets>
<portlet addview="portlets.Calendar" remove="true" />
</portlets>
感謝David Glick爲我們找到了一個。
如果我正確讀取代碼,還可以通過Portlets.xml中的GenericSetup註銷portlet類型;例如 –
2011-05-05 20:24:54
你是對的;我第一次錯過了它,因爲它直接使用組件API。我會更新答案。 – 2011-05-07 10:38:41