Creating static text portlets in Plone 3.0
This How-to applies to:
Plone 3.0.x
This How-to is intended for:
Integrators, Customizers
Introduction
Plone.portlet.static is another great contribution from Martin Aspeli. It is very handy if your web editors want a portlet type they can easily drop static html content into and have a spash image, flash video or email sign up form display on their site. I will run through how to set this up in a unified installer or buildout install of Plone, show an example of how to customise the portlets to not display a title and describe some example of its use.
Basic Setup
Install in Unified Installer build of Plone 3
As plone.portlet.static is packaged as an egg rather than a old style plone product the first step is to install easy_install:
$ wget http://peak.telecommunity.com/dist/ez_setup.py $ sudo /opt/Plone-3.0.2/bin/python ez_setup.py -U setuptools
This will install easy_install in /opt/Plone-3.0.2/Python-2.4.4/bin
You can then install plone.portlet.static through the following steps:
1. Install the package into /opt/Plone-3.0.2/Python-2.4.4/lib/python2.4/site-packages directory:
$ sudo ./Python-2.4.4/bin/easy_install plone.portlet.static
2. Add the zcml slug in /opt/Plone-3.0.2/zeocluster/client2/etc/packages-includes folder, the file is named "plone.portlet.static-configure.zcml" and contains:
<include package="plone.portlet.static" file="configure.zcml" />
You will need to copy this file to the client1 packages-includes folder in order to make this package work in the first zeocluster client.
3. Restart the zope instance:
$ sudo /opt/Plone-3.0.2/zeocluster/bin/restartcluster.sh
4. Install the product via "Add Remove Products"
Installing in a buildout build of Plone 3
If you have a install of plone using buildout the steps to install it are quite easy.
1. Add " plone.portlet.static" to the list of eggs and to the "zcml" section in buildout.cfg
2. run ./bin/buildout
3. start the zope instance "./bin/instance fg"
4. Install the new product view "Add Remove Products" or the plone_quickinstaller. I used "Add Remove Products" within the plone site.
The next step
Adding a static portlet to your site
The process to add a static portlet now is:
1. Click on the "Manage Portlets" link at the bottom of the portlets.
2. From an "Add portlet" dropdown select "Static text portlet"
3. Enter a title for your portlet, this is required. We might well want to customise the static portlet package so that this is not required or we provide an option whether we display it or not.
4. Enter your html into the "Text" area, this will be rendered in the portlet.
5. Enter a footer if you want one (optional)
6. Enter a link that you want the footer and the header to go to (optional)
Making the portlet header optional
As our website manager wants to be able to use this portlet to display just a linked image or a flash video we needed to make the display of the portlet header optional. It is quite easy to change the static.pt and static.py file so that the header is not required. The one issue with not having the title filled in is that it is used in the manage portlets to see what the name of the individual portlets are. To get around that I created another field "portlet_title" and used that in the view "static.pt"
I have attached the new versions of static.pt and static.py
The website manager can now create a static text portlet and leave the Portlet Title blank and only have the html that was entered in the text area part being displayed:

Here is an example of some of the portlets created using the static text portlet type. The first is the one resulting from the screen shot above. The second is an example of the use of the Spry Ajax toolkit to display content via tabs while the last is the result of javascript that displays a flash video.

Further information
This howto is the result of comments on the following howto: http://plone.org/documentation/how-to/editable-static-text-portlets
For more detail on easy_install, eggs and buildout see http://plone.org/documentation/tutorial/buildout/introduction
For more information of plone.portlet.static included more detailed installation guide see http://svn.zope.de/plone.org/plone/plone.portlet.static/tags/1.0b2/docs/
Re: Thanks!
cheers
John
Nice but for multiple static portlets ?
My problem is that I'm new in PLone3.0 and I just can't find where to modify the static.pt code.
Thanx
Re: Nice but for multiple static portlets ?
/opt/Plone-3.0.2/Python-2.4.4/lib/python2.4/site-packages/plone.portlet.static-1.0b3-py2.4.egg/plone/portlet/static/static.pt
for example. If you are using buildout then the package will be installed in your eggs directory.
Instructions broke Plone
<PloneSite at broken>
I can get into the ZMI. The Plone object has an icon and message in parentheses showing it's broken. When I click on it, it says:
"This object is broken because the CMFPlone product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance.
"Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled."
I've deleted plone.portlet.staic in package-includes and restarted Zope, but Plone is still broken.
Any ideas?
Fixed - I hope
I got Plone back after modifying the zopectl scripts to add the path to the modules:
PYTHONPATH="$SOFTWARE_HOME:/opt/Plone-3.0.3/zeocluster/lib/python:$PYTHONPATH"
(The part between "/opt" and "/python" is what I added.)
This got Plone going again.
To see the product and be able to install it, I also had to rename the zcml slug, to plone.portlet.static-configure.zcml.
One more thing
Corrected in Howto
No problem
I wonder what caused the problems with my sys.path. Maybe you also should add information about adding that in zope.conf.
It works but is it the right way
Thanks.
And thanks for the how-to!
same problem
What do you mean by "zcml slug"? As I understood this, all I have to do is make a file in /opt/Plone-3.0.4/zeocluster/client1/etc/package-includes/ named plone.portlet.static-configure.zcml and with this content:
<include package="plone.portlet.static" />
or:
<include package="plone.portlet.static" file="configure.zcml" />
(does not make any difference). Copy the file to client2, also.
Same Case - Plone broken
I followed step by step this how-to, and my installation of Plone.3.0.6 broke.
Also I try the PYTHONPATH bit, but it did not work.
I hope for nest How-to's the instructions were clearer and specify for which Plone versions they work.
Thanks...
Information such as "title", "footer" in Chinese can not be make out portlet displays..:(
Problem with run?
Incompatible with plone3.0
We already have: plone.app.form 1.0.4 but plone.portlet.static 1.1rc2 requires 'plone.app.form>=1.1dev'.
Wiggy told me on #plone that the most recent versions of plone.portlet.static (which are kupu enabled) do not work on plone3.0. Lukily `plone3.1`_ ships with static portlets included.
.. _`plone3.1`: http://plone.org/products/plone/releases/3.1
Thanks!
Your modification for optional title is a really sensible one; I hope you'll consider contributing it back to the trunk of plone.portlet.static.