Reputation: 5335
How I can reorder the portlets so that inherited, parent portlets come before the current item's portlets?
Upvotes: 2
Views: 108
Reputation: 2876
Mathias solutions seem to be the easier ones; anyway I want to leave this documented in case you don't want to install a third party product.
You can change the way portlets are ordered just by writing an adapter. The following one, for instance, reorder the portlets on any object providing the IATImage interface (images) so the content type portelts are rendered first, then the group ones, and the context ones at last:
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
Don't forget to register your adapter using the following on your ZCML file:
<configure xmlns="http://namespaces.zope.org/zope">
...
<adapter factory=".adapters.PortletRetriever" />
...
</configure>
Upvotes: 5
Reputation: 6839
There are two solutions I'm aware of
collective.weightedportlets
You can define a weight for each portlet, no matter in which section/group the portlet is (user, context, type, inherited). Version 1.1 is Plone 4.3 compatible.
Solgema.PortletsManager
Basically does a similar thing like collective.weightedportlets, but it can be done by D'n'D and it extends the UI of manage-portlets
.
Of yours you could hack into the portlet retriever, but I'm not recommend that.
PS: If you want to write your own portlet retriever, also check collective.weightedportlets :-)
More about how plone renders portlets.
Upvotes: 4