Adding Portlet Managers
This How-to applies to:
Plone 3.0.x
This How-to is intended for:
Integrators, Customizers, Developers
This is about adding Portlet MANAGERS, hint: PortletManager != Portlet. A PortletManager is a kind of container for the portlets, like the ViewletManager is for Viewlets. So, after reducing the momentum of misunderstanding, lets start:
Prerequsites
I assume you're familar with GenericSetup based setups for Plone 3. Take a look at DIYPloneStyle and related tutorials if not.
You need Plone 3 installed and a Product NEWTHEME for your own skin (based on DIYPloneStyle works fine).
Strategy
In my example I don't want to customize the main-template. So the idea is to add a viewlet to the plone.app.layout.viewlets.interfaces.IContentViews viewletmanager. So the steps need to be done is
- Add a viewlet to the viewlet-manager
- Add a portlet-manager
- Add a management view for the portlet-manager.
Step One: Add a viewlet
in Products.NEWTHEME add a file abovecontentportlets.pt containing:<tal:block replace="structure provider:my.abovecontentportlets" />
Here we call the portlet manager, we create it in step two.
But first lets register our new viewlet for the viewletmanager.
Edit your Products/NEWTHEME/configure.zcml and add:
<browser:viewlet name="my.abovecontentportlets" manager="plone.app.layout.viewlets.interfaces.IContentViews" template="abovecontentportlets.pt" permission="zope2.View" />
Step Two: Add a portlet manager
Create a marking interface for the manager and add or edit Products/NEWTHEME/interfaces.py
from plone.portlets.interfaces import IPortletManager class IMyAboveContent(IPortletManager): """we need our own portlet manager above the content area. """
Add (or edit) your Products/NEWTHEME/profiles/default/portlets.xml and register a portlet manager:
<?xml version="1.0"?> <portlets> <portletmanager name="my.abovecontentportlets" type="Products.NEWTHEME.interfaces.IMyAboveContent" /> </portlets>
Thats all you need if you don't want to manage the portlets through the web. Oh, you want to? So you need a third step:
Step Three: Add a management view for the portlet manager
The management view is rendered for the left and right slots directly on the main-template. But we use a viewlet and in here we have a different view. so we need to call explicitly our view and call the our manager within its context.
We need to register a new browser view for an own page template directly calling our manager. Again add some lines to your configure.zcml:
<browser:page for="plone.portlets.interfaces.ILocalPortletAssignable" class="plone.app.portlets.browser.manage.ManageContextualPortlets" name="manage-myabove" template="templates/managemyabove.pt" permission="plone.app.portlets.ManagePortlets" />And finally we need the template, so add an file managemyabove.pt and edit it:
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:metal="http://xml.zope.org/namespaces/metal"
xmlns:tal="http://xml.zope.org/namespaces/tal"
xmlns:i18n="http://xml.zope.org/namespaces/i18n"
metal:use-macro="context/main_template/macros/master"
i18n:domain="plone">
<head>
<div metal:fill-slot="javascript_head_slot" tal:omit-tag="">
<link type="text/css" rel="kinetic-stylesheet"
tal:attributes="href string:${context/absolute_url}/++resource++manage-portlets.kss"/>
</div>
</head>
<body>
<div metal:fill-slot="main">
<h1 class="documentFirstHeading">Manage My Portlets</h1>
<span tal:replace="structure provider:my.abovecontentportlets" />
</div>
</body>
</html>
That's it. After restarting your zope you can call http://DOMAIN.TLD/plone/path/to/some/context/@@manage-myabove
and assign portlets over your content.
removing
Not working for 3.0.2 ?
I am really a newbie sorry, thanks anyway in advance :)
('No traversable adapter found', {u'content': [('version', '1.6'), ('mode', 'html'), ('setPosition', (99, 16)), ('setSourceFile', 'file:C:\\Program Files (x86)\\Plone 3\\Data\\Products\\CMFPlone\\skins\\plone_templates\\main_template.pt'), ('beginScope', {u'tal:define': u'show_border context/@@plone/showEditableBorder', u'metal:define-macro': u'content', u'tal:attributes': u"class python:test(show_bor...
.
.
.
...MANY PAGES...
Me too
I did some Googling. It seems many people are seeing it.
Work in a fresh plone instance
How new?
How "new"? I was doing this on a site I created a few days ago.
Serveral problems
1. How do i make the navigation-portlet addable to the new portlet-manager?
2. How do you uninstall such a product? When I uninstall the product the DIYPloneStyle skin still stays addable in the @@skins-controlpanel
3. Why do you put managemyabove.pt in the folder /templates but not abovecontentportlets.pt?
regards, philip
it would be nice...
How to make the navigation portlet available
In step two I changed "class IMyAboveContent(IPortletManager):" to "class IMyAboveContent(IPortletManager, IColumn):". This makes it possible to add e.g. the navigation portlet (search for portlets.Navigation in "CMFPlone/profiles/default/portlets.xml" to understand why, or read "http://plone.org/products/plone/roadmap/205").
Also, in step one, I added this to the viewlet registration in order to limit the scope to just my theme (thereby avoiding errors when creating further plone instances):
layer=".interfaces.IThemeSpecific"
This was all with Plone 3.1.2.
Error in my.abovecontentportlets
return expression(self)
File "/home/tpw/Plone-3.0.6/lib/python/Products/Five/browser/providerexpression.py", line 25, in __call__
raise cp_interfaces.ContentProviderLookupError(name)
ContentProviderLookupError: my.abovecontentportlets
Sugestions?
Re: Error in my.abovecontentportlets
Common error
zope.configuration.config.ConfigurationExecutionError: zope.component.interfaces.ComponentLookupError: (<InterfaceClass zope.security.interfaces.IPermission>, 'plone.app.portlets.ManagePortlets')
Just add <include package="plone.app.portlets" /> in your configure.zcml file !
Navigation portlet
Thanks for help.