Creating a static-text portlet

The simplest portlet you can make: static, with no special logic.

To create a portlet containing static text, save the following code in a page template called portlet_static in the Custom folder of your portal_skins.

Code:

  <html xmlns:tal="http://xml.zope.org/namespaces/tal"
        xmlns:metal="http://xml.zope.org/namespaces/metal"
        i18n:domain="plone">

  <body>

  <!-- The static box -->

  <div metal:define-macro="portlet">

      <div class="portlet" id="portlet-static">

          <h5 i18n:translate="box_statis">Your Title</h5>

          <div class="portletBody">

              <div class="portletContent odd">

                  Your static content here

              </div>

              <div class="portletContent even">

                  More static content here

              </div>

          </div>

      </div>

  </div>

  </body>

  </html>

You can call this from a right or left slot with here/portlet_static/macros/portlet.

this doesn't work

Posted by Jon Block at Mar 31, 2006 02:20 AM
I signed up for my first plone site with zettai.net and I tried this tutorial ... here's what I got:

Site Error
An error was encountered while publishing this resource.

AttributeError

Sorry, a site error occurred.

Traceback (innermost last):

Module ZPublisher.Publish, line 175, in publish_module_standard
Module Products.PlacelessTranslationService.PatchStringIO, line 51, in new_publish
Module ZPublisher.Publish, line 132, in publish
Module Zope.App.startup, line 204, in zpublisher_exception_hook
Module ZPublisher.Publish, line 101, in publish
Module ZPublisher.mapply, line 88, in mapply
Module ZPublisher.Publish, line 39, in call_object
Module Products.CMFCore.PortalContent, line 116, in __call__
Module Shared.DC.Scripts.Bindings, line 306, in __call__
Module Shared.DC.Scripts.Bindings, line 343, in _bindAndExec
Module Products.CMFCore.FSPageTemplate, line 191, in _exec
Module Products.CMFCore.FSPageTemplate, line 124, in pt_render
Module Products.PageTemplates.PageTemplate, line 96, in pt_render

You are right

Posted by Toby Malek at Sep 09, 2006 07:50 PM
Hi, you are right, it can not work. It is just becouse of a simple problem.

you should remove word: "portlet" after here/...

here/portlet_static/macros/portlet
you should right:
here/static/macros/portlet

it is not a finished portlet from Zope and plone can not find it in portlet files

have fun,

:)

Still can't get it to work

Posted by Thando Tettey at Sep 11, 2006 11:51 AM
i have saved the template both as portlet_static and static
then added the line
here/static/macros/portlet

I still gives an exception. attribute error

pliz help...

What version??

Posted by Carla Delgado at Oct 08, 2006 12:16 PM
Hi there, I just tryied it here, with plone 2.5, and it worked fine with no changes to the original suggestion. What version of Zope / Plone are you using?

To which slot have you added it?

Width problem

Posted by Martin Dart at Sep 11, 2006 09:16 AM
I have created my portlets fine, but they do not display their width correctly in IE7.

Can this width be forced, to display constantly in all browsers?

Change in plone 2.1.x and onwards

Posted by Max Bloechle at Nov 10, 2006 10:21 PM
It looks as if things have changed in plone versions 2.1.x and onwards (according to http://plone.org/documentation/how-to/formatting-portlets). The up-to-date version would look something like:

<html xmlns:tal="http://xml.zope.org/namespaces/tal"
      xmlns:metal="http://xml.zope.org/namespaces/metal"
      i18n:domain="plone">
<body>

<!-- The static box -->
<div metal:define-macro="portlet" tal:omit-tag="">
    <dl class="portlet" id="portlet-static">
       <dt class="portletHeader">Title</dt>
       <dd class="portletItemSingle odd">Some content</dd>
       <dd class="portletItemSingle even">Some content</dd>
       <dd class="portletItemSingle odd lastItem">Last item</dd>
    </dl>
</div>

</body>
</html>

Don't forget the lastItem tag (even if it is the only and first row), otherwise you will get a double border at the end of the portlet (and possibly other issues)...

Have fun and a happy migration to plone 2.5!

plone 2.5

Posted by Max Bloechle at Nov 13, 2006 08:04 PM
As deprecated.css in plone 2.1.2 states ("/* Classes that were introduced erroneously in Plone 2.1. Will disappear in 2.5. */") dd.portletItemSingle is being replaced by portletItem and dd.lastItem is removed, resulting in:
 
<!-- The static box -->
<div metal:define-macro="portlet" tal:omit-tag="">
 <dl class="portlet" id="portlet-static">
 <dt class="portletHeader">Title</dt>
 <dd class="portletItem odd">Some content</dd>
 <dd class="portletItem even">Some content</dd>
 <dd class="portletItem odd">Last item</dd>
 </dl>
</div>