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 https://github.com/collective/wm.sampledata
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.
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":http://svn.plone.org/svn/collective/adi.simplestructure/trunk/adi/simplestructure/profiles/default/portlets.xml
@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: http://docs.plone.org/develop/plone/functionality/portlets.html#hiding-unwanted-portlets
IF you want to add a new Static Custom portlet pro grammatically than you have to do certain thing as as following
@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 https://github.com/collective/wm.sampledata.
Ok, David Bain thanks for the update.
can you share your final code?
Code of Conduct –
Hosting courtesy of Rackspace