2011-08-16 36 views
5

在plone.org上使用documentation以及論壇中的一些內容,我能夠在Plone 4.0.8中的內容下面獲得一個定製portlet管理器。實際上,目標是將4個自定義管理器安排在儀表板之下的內容之下。如何將庫存Portlet(從plone.app.portlets)添加到我的自定義Portlet管理器?

無論如何,我的經理只允許我添加靜態和收集portlet。在代碼中查看後,我發現當系統填充「添加新的portlet」下拉列表時,它會遍歷所有portlet。然後,它遍歷每個portlet的「for_」屬性檢查,以查看接口是否由自我提供 - 我的portlet管理器。

def getAddablePortletTypes(self): 
    addable = [] 
    for p in getUtilitiesFor(IPortletType): 
     # BBB - first condition, because starting with Plone 3.1                                 
     #every p[1].for_ should be a list                                       
     if not isinstance(p[1].for_, list): 
      logger.warning("Deprecation Warning ..." % p[1].addview) 
      if p[1].for_ is None or p[1].for_.providedBy(self): 
       addable.append(p[1]) 
     elif [i for i in p[1].for_ if i.providedBy(self)]: 
      addable.append(p[1]) 
    return addable 

如何將我的管理器接口添加到每個portlet的for_接口列表?

+2

我改變了我的經理從接口 '類IBottomPortletManager(IPortletManager)' 到 '類IBottomPortletManager(IPortletManager,IColumn)' IColumn在plone.app.portlets定義的,所以這些門戶都已經註冊了提供IColumn的經理。 現在,這是做到這一點的理想方式嗎? – Travv15

回答

6

您的comment可能是最好的方法。這裏的關鍵是portlet本身被註冊到portlet管理器接口,以及用於上下文,圖層等的其他接口。例如,另一種方法是在profiles/default/portlets.xml中添加其他註冊文件到你的portlet管理者接口,每個小門戶的你想的可加成:

<portlet 
    addview="portlets.News" 
    title="News" 
    description="A portlet which can render a listing of recent news" 
    i18n:attributes="title; 
        description" 
    > 
    <for interface="your.package.IYourPortletManager" /> 
</portlet> 

你的方法可能是最好的,但是,因爲它聽起來像你創建一個柱狀portlet管理者。但是,您可以從基類中移除IPortletManager,因爲IColumn已經將其子類化了。

+0

出於好奇,我將如何添加額外的註冊到我的經理界面?假設我只使用IPortletManager作爲基礎,但我也想要新聞portlet。我如何將我的管理界面添加到News portlet註冊中?我一直在找plone.app.portlets試圖弄清楚這些portlet如何在沒有任何運氣的情況下注冊接口。 – Travv15

+0

用一個例子更新了我的答案。 –

相關問題