[Product-Developers] Show/Hide Portlets

Andreas Jung lists at zopyx.com
Wed Jan 7 06:15:03 UTC 2009

On 07.01.2009 6:55 Uhr, hannesc wrote:
> I am busy doing a theme as a stand-alone product and I was wondering if there
> was a way of telling Plone 3 to hide all portlets except the one that I
> specify (these would be custom templates that I created).
> Eg. I need all portlets in column two to be disabled, and only the search
> and navigation portlets to be displayed in column one (in that order).

Example code from a late project (you have to adjust it yourself
to your needs):

from Acquisition import aq_inner
from Products.Five.utilities import marker
from plone.app.layout.navigation.interfaces import INavigationRoot
from zope.component import getMultiAdapter, getUtility
from plone.portlets.interfaces import IPortletManager
from plone.portlets.interfaces import ILocalPortletAssignmentManager
from plone.portlets.interfaces import IPortletAssignmentMapping
from plone.app.portlets.interfaces import IPortletPermissionChecker

from plone.portlets.constants import USER_CATEGORY
from plone.portlets.constants import GROUP_CATEGORY
from plone.portlets.constants import CONTENT_TYPE_CATEGORY
from plone.portlets.constants import CONTEXT_CATEGORY

marker.mark(context, INavigationRoot)

for name in ('plone.leftcolumn', 'plone.rightcolumn'):

     portletManager  = getUtility(IPortletManager, name=name)
     assignable = getMultiAdapter((context, portletManager,), 
     assignments = getMultiAdapter((context, portletManager), 


     assignable.setBlacklistStatus(GROUP_CATEGORY, None)
     assignable.setBlacklistStatus(CONTENT_TYPE_CATEGORY, None)
     assignable.setBlacklistStatus(CONTEXT_CATEGORY, True)

from plone.app.portlets.portlets import navigation
portletManager  = getUtility(IPortletManager, name='plone.leftcolumn', 
left = getMultiAdapter((context, portletManager,), 
IPortletAssignmentMapping, context=context)
left[u'navigation'] = navigation.Assignment()

return 'done'

ZOPYX Ltd. & Co. KG - Charlottenstr. 37/1 - 72070 Tübingen - Germany
Web: www.zopyx.com - Email: info at zopyx.com - Phone +49 - 7071 - 793376
Registergericht: Amtsgericht Stuttgart, Handelsregister A 381535
Geschäftsführer/Gesellschafter: ZOPYX Limited, Birmingham, UK
E-Publishing, Python, Zope & Plone development, Consulting

-------------- next part --------------
A non-text attachment was scrubbed...
Name: lists.vcf
Type: text/x-vcard
Size: 316 bytes
Desc: not available
URL: <http://lists.plone.org/pipermail/plone-product-developers/attachments/20090107/43b84ef0/attachment.vcf>

More information about the Product-Developers mailing list