plone 6.1 classic custom portlet

Good Morning!

I'd like to create my own custom portlet in 6.1. I found a description in Portlets — Plone Documentation v6. But I guess it's deprecated. I took a look at plone.app.portlets, but I could'nt found any hints there. Your help would be appreciated.

Have a nice weekend!
Cheers
Jens

Why do you think it’s deprecated?

@jensens wrote this example about 3 years ago for Plone 6.

If it needs to be updated, we’d gladly accept a pull request.

in 6.1, some configure.zcml expressions are no more working, I guess. This version works:

<plone:portlet
    name="my_portlet"
    interface=".my_portlet.IMyPortlet"
    addview=".my_portlet.AddForm"
    assignment=".my_portlet.Assignment"
    renderer=".my_portlet.Renderer"
/>

title and description are defined now in code I guess, and name is mandatory.

I'm not a good coder, but I will try to fix it for 6.1 if I find a solution and the time :slight_smile:

OR, I did it in a wrong way. In the doc:

To register this portlet with Plone, you will need to create a configure.zcml file that tells Plone about the portlet.

What I did: I added the portlet configuration to the browser/configure.zcml, maybe this is my problem.

ok, I made it!

In 6.1, you have to register the portlet with a 'profiles/default/portlets.xml' file like:

<?xml version="1.0"?>
<portlets>

  <portlet
      addview="mastodon_portlet"
      title="Mastodon Portlet"
      description="Demo portlet"
      />

</portlets>

and with this lines added to 'browser/configure.zcml'

<plone:portlet
    name="mastodon_portlet"
    interface=".mastodon_portlet.IMastodonPortlet"
    addview=".mastodon_portlet.AddForm"
    editview=".mastodon_portlet.EditForm"
    assignment=".mastodon_portlet.Assignment"
    renderer=".mastodon_portlet.Renderer"
/>

template and class are named 'mastodon_portlet.py' and 'mastodon_portlet.pt' by using the code from the original example.

in a project recently created using cookieplone, I have created fully functional portlets running the following command in the backend folder:

uvx plonecli --with bobtemplates.plone==7.0.0b1 add portlet

wow, thanks, works great!

For me, plonecli does'nt work very well (python-3.13), but I could run mrbob:

mrbob bobtemplates.plone:portlet

So there is now a portlets/configure.zcml

<configure
  xmlns="http://namespaces.zope.org/zope"
  xmlns:browser="http://namespaces.zope.org/browser"
  xmlns:plone="http://namespaces.plone.org/plone">

  <include package="plone.app.portlets" />

  <!-- '-*- extra stuff goes here -*-' -->

  <plone:portlet
    name="example.portlets.Weather"
    interface=".weather.IWeatherPortlet"
    assignment=".weather.Assignment"
    renderer=".weather.Renderer"
    addview=".weather.AddForm"
    editview=".weather.EditForm" />
    
</configure>

looks similar to my self created file.

But, after reinstall the addon, the new weather portlet doesnt appear in the portlet manager. I guess you have to register it in addition as I did it.

you need to register it also in portlets.xml under profiles/default.

plonecli should have handled it…

the code is something like this (this is for my portlet )

  <portlet
      addview="dantzan.portlets.Nextmonthcalendar"
      title="Next Month Calendar"
      description="A portlet to show next month calendar."
      i18n:attributes="title; description"
      />

And then you need to reload the profile from portal_setup

Ahh, I see. mrbob does not register the portlet, but plonecli does.

Thanks for your help!

1 Like