How to programmatically add a new static portlet

I'm looking for a way to programmatically set some footer portlets in Plone 5. I have a script which uses the plone.api to create new content, but I don't see an similarly elegant approach for creating a new static portlet in target portlet manager.

After some digging, this package is looking like my best bet

Specifically this "addPortlet" utility


Wouldn't using GS be the easiest way? Look how Plone core installs portlets with GS perhaps?


I'll vouch for the GS way of adding a portlet at add-on activation time. Was really easy to do.

1 Like

Agree with @vangheem and @tkimnguyen, here's an example for a header- and a footer-portlet, in conjunction with one of my fav-addons "Products.ContentWellPortlets":

@ida, @tkimnguyen and @vangheem thank you for pointing this out, looks much simpler than what I was doing. The addPortlet approach did work btw, though it caused all sorts of mental contortions. Now I have to go find some use for my "hacky" approach. .

I'm also looking at documentation on removing portlets here:

IF you want to add a new Static Custom portlet pro grammatically than you have to do certain thing as as following :-1:

  1. Create your own custom addon product (Basic) using paster or mr.bob product skeleton script in your src directory,
  2. once your product skeleton has been created then you should create a portlets directory into your own product and register this directory in configure,zcml( ) .
  3. Inside the Portlet directory you have to create one more configure.zcml where you define your prottlet name and its functionality
  4. Create and where you define your html code anf python code logic.
  5. Refer Creating, Customizing, and Assigning Portlets Automatically here

@jitesh43 this isn't what I was looking for, as this defines a brand new portlet. I wanted to be able to control an existing portlet type (Static portlet). I was able to successfully do so by borrowing ideas from

Ok, David Bain thanks for the update.

can you share your final code?