plone.portlets

published Oct 10, 2007, last modified Jan 30, 2008

Plone conference 2007, Naples. Speaker: Geir Baekholt

Plone conference 2007, Naples. Speaker: Geir Baekholt

The left_slots and right-slots properties are probably the oldest piece of Plone that is sill in 2.5. It is at least seven years old. It is not working really nice for users or developers.

Then we had PlonePortlets. With this product, portlets became content objects (which is not terribly nice). They worked but has many side effects.

In April 2006 we had the Archipelagosprint in which we spent time thinking about portlets and coding a bit. Then everyone went home and did nothing about it. Except Martin Aspeli (optilude on irc). He almost singlehandedly (well, with help by Philipp von Weitershausen) coded plone.portlets and plone.app.portlets which is in Plone 3.0.

In Plone 3.0 portlets are objects, not templates (although there are templates in the background of course, to actually show the portlets in the browser).

Default portlets are the login portlet, navigation, calendar, recent items, news, events, search, RSS feed (though it does not work), review list and the classic portlet (which we will see later).

Adding portlets is now more involved than just setting the left_slots and right_slots properties. They can be assigned to context, users/groups and content types.

With the Manage Portal permission you have a link at the bottom of the left and right slots to a page for managing the portlets of that context. You can also block portlets in subfolders. Due to a bug this does not work in Plone 3.0, but it does work in 3.0.1.

Often you want to have a portlet that is only visible to for example the finance department. You can now do this in the Group Management in the Plone Control Panel. Go to the Group Portlets tab and add left and right portlets there for this group.

You can have user portlets. A user can add portlets in his personal dashboard. Click on the user name (next to logout usually). Edit your dashboard there and add your favorite portlets.

There is a static portlet in the collective. It is a good example that you can copy. Also look at the Collection portlet, which can come in place of the News and Recent Items portlets.

These new portlets are a bit more complex than the old ones. For backwards compatibility there is the Classic portlet so you can still use them (with all its downsides of course).

Portlets are not viewlets. Portlets are persistent. Viewlets are defined in zcml.

Porlets have at least: interface, assignment, renderer. Possibly also an add form, edit form. Interface describes what it looks like (it has a header attribute in our case), inheriting from IPortletDataProvider. The Assignment class implements that Interface. The Renderer class renders the portlet (mostly using a template). It also has a method available so you can use that to conditionnally show the portlet. You wrap all this up with some lines in a zcml file.

In the future we want to have more GenericSetup support for this so you can define portlet assignments in xml so you do not need to write code for this. (Are there any volunteers?) We need widgets for more advanced configuration. We need more reusable portlets. Try it! We also may come up with a paster template that you can use as a starting point for your own portlet.