Using the documentation on plone.org along with some in the forum, I was able to get a custom portlet manager below my content in Plone 4.0.8. The goal, actually, is to have 4 custom managers below the content arranged like the dashboard.
Anyway, my manager only allows me to add static and collection portlets. After looking around in the code, I found that when the system goes to populate that 'Add new portlet' dropdown, it loops through all of the portlets. Then, it loops through each portlet's 'for_' attribute checking to see if the interfaces are provided by self--my portlet manager.
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
How do I add my manager's interface to each portlet's 'for_' list of interfaces?
Your comment is probably the best way to do this. The crux here is that portlets themselves are registered to a portlet manager interface, among other interfaces for contexts, layers, etc.. Another way to do this, for example, would be to add additional registrations in your profiles/default/portlets.xml file to your portlet manager interface for each of the portlets you want addable:
<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>
Your way is probably best, however, since it sounds like you are creating a columnar portlet manager. You could remove IPortletManager from the base classes, however, since IColumn already subclasses it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With