Personal tools
You are here: Home Documentation How-tos Creating a static-text portlet
Support

Get Help

Join our chat rooms or support forums if you have more specific questions.

Plone Training
Learn how to design, build, and deploy a website in Plone through one of the numerous Plone training sessions around the world.
Find Plone training…
 
Document Actions

Creating a static-text portlet

This How-to applies to: Any version.
This How-to is intended for: Integrators, Customizers

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.

by runyaga — last modified August 31, 2007 - 16:20 All content is copyright Plone Foundation and the individual contributors.

this doesn't work

Posted by jonblock at March 31, 2006 - 02:20

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 mediamalek at September 9, 2006 - 19:50
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 thandotettey at September 11, 2006 - 11:51
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 cdelgado at October 8, 2006 - 12:16
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 mjdart at September 11, 2006 - 09:16
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 max1001 at November 10, 2006 - 22:21
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 max1001 at November 13, 2006 - 20:04
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>

For any issues with the web site functionality, please file a ticket.

Please consult the policy on plone.org content if you want your content published on this site.

Servers and hosting by