Personal tools
You are here: Home Documentation How-tos Adding Portlet Managers
Support

Get Help

Join our chat rooms or support forums if you have more specific questions.

Plone Training
Learn how to design, build, and deploy a website in Plone through one of the numerous Plone training sessions around the world.
Find Plone training…
 
Document Actions

Adding Portlet Managers

This How-to applies to: Plone 3.0.x
This How-to is intended for: Integrators, Customizers, Developers

You need portlets at an additional place in your Plone. In this example we put contextual portlets above the content.

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

  1. Add a viewlet to the viewlet-manager
  2. Add a portlet-manager
  3. 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.

 

by Jens W. Klein last modified November 23, 2007 - 21:49 All content is copyright Plone Foundation and the individual contributors.

Navigation portlet

Posted by Patrice Lespagnol at October 14, 2007 - 17:45
Thanks for this how-to. I've follow it to put a navigation portlet on the top of the content column of my site. Alas when I manage TTW my portlet manager, I don't have the choice to add a navigation portlet : the menu does not carry this option.
Thanks for help.

removing

Posted by Kim Chee Leong at October 18, 2007 - 13:38
How can I remove a portlet manager? I tried adding remove="true" but that didn't help.

Not working for 3.0.2 ?

Posted by Cagil Duman at November 1, 2007 - 11:00
On Plone 3.0.2 Windows version, already working DIY generated NEWTHEME crashes with the following error (in fact site turns into Matrix) after this method is applied. I don't know if this is unique to my setup. I have also tried with fresh installation with no other product is present. Also a google result points out that Python setup tools should be installed for these types of errors; anyway latest version already seems to be set up as default as I see it under site.packages directory. Some other result points out that after Zope 2.10 traversable method bla bla bla...

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

Posted by Chris Williamson at November 23, 2007 - 05:38
I'm getting this same weird error.

I did some Googling. It seems many people are seeing it.

Work in a fresh plone instance

Posted by Jens W. Klein at November 23, 2007 - 21:45
So, I just tried to find the bug. I got it too. It happens if you apply all written here on a existing Plone. If you do create a new site with your own profile, all works fine. I didnt digged deeper. Will update you if I found a solution.

How new?

Posted by Chris Williamson at November 24, 2007 - 02:17
"Create a new site with your own profile"

How "new"? I was doing this on a site I created a few days ago.

Serveral problems

Posted by pbauer at December 17, 2007 - 10:36
Thanks for the how-to! However I have some questions:
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...

Posted by pepe_bz at March 27, 2008 - 10:24
i think it could be very useful to expand this howto to the case where someone is making a plone3_theme with paster and to the an other one to add portletmanagers to the main_template.

How to make the navigation portlet available

Posted by Karl Johan Kleist at June 8, 2008 - 03:47
Jens, this tutorial saved my day!

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

Posted by Herson Rodrigues at June 9, 2008 - 18:59
File "/home/tpw/Plone-3.0.6/lib/python/zope/tales/tales.py", line 696, in evaluate
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

Posted by Laurent Lasudry at July 5, 2008 - 09:22
Don't forget to import portal_setup steps ;-)

Common error

Posted by Laurent Lasudry at July 5, 2008 - 09:24
If you get this error when starting instance :

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 !

For any issues with the web site functionality, please file a ticket.

Please consult the policy on plone.org content if you want your content published on this site.

Servers and hosting by