Attention

This document was written for an unsupported version of Plone, Plone 2.1.x, and was last updated 1240 days ago.

For more information, see the version support policy.

To learn how to upgrade to the current version of Plone, read the upgrade manual.

Utilizing the template

by Mikko Ohtamaa last modified Dec 30, 2008 03:05 PM
How to change existing portlets to use image frame template

Stock Plone 2.1.x is doesn't have fill-slot mechanism for portlets. This means a lot of manual work for us: Every portlet macro you are going to use at your site must be manually modified to take the advantage of the image frame template and fill-slots. I hope this will be changed in the future versions of Plone and personally I am glad to help in such a task. Plone's militaristic 90 degree corners give imago like Plone was the content management system of 70s functional Soviet Russian. This might affect a bit in the harsh competition of modern CMS UIs.

You cannot always simply replace <div> definitions with <metal fill-slot> calls, since there are some restrictions how TAL handles variables. In fill-slot scope variables defined outside the call might not be valid and must be redeclared.

Here I have modified portlet_prefs (preference portlet as example). Changes are bolded.

Orignal
Modified
<html xmlns:tal="http://xml.zope.org/namespaces/tal"
xmlns:metal="http://xml.zope.org/namespaces/metal"
i18n:domain="plone">
<body>
<metal:portlet define-macro="portlet"
tal:define="controlPanel python:modules['Products.CMFCore.utils'].getToolByName(here, 'portal_controlpanel');
groups python:controlPanel.getGroups('site');
getIconFor nocall:putils/getIconFor">


<dl class="portlet"
id="portlet-prefs">

<dt class="portletHeader"><span i18n:translate="heading_control_panel">Site Setup</span></dt>

<dd class="portletItem"
tal:repeat="group groups">


<strong tal:content="group/title"
i18n:translate="">Plone Configlet Group Title</strong>
<ul class="configlets" tal:define="configlets python:controlPanel.enumConfiglets(group=group['id'])">

<li tal:repeat="configlet configlets">
<a href=""
style="display: block;"
tal:attributes="href configlet/url"
tal:condition="configlet/visible">
<img src="" alt="" tal:attributes="src python:getIconFor('controlpanel',configlet['id']);
alt configlet/description"
i18n:attributes="alt"
tal:on-error="string:" />
<tal:configletname tal:content="configlet/name"
i18n:translate=""></tal:configletname>
</a>
</li>

<li tal:condition="not:configlets" i18n:translate="label_no_panels_available">
No Preference Panels available.
</li>

</ul>

</dd>

</dl>

</metal:portlet>
</body>
</html>








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

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

<div metal:use-macro="here/portlet_slot/macros/portlet">


<dl class="portlet" id="portlet-prefs">

<div metal:fill-slot="portlet-header" class="portletHeader">
<span i18n:translate="heading_control_panel">Site Setup</span>
</div>


<div metal:fill-slot="portlet-body" class="portletContentArea"
tal:define="controlPanel python:modules['Products.CMFCore.utils'].getToolByName(here, 'portal_controlpanel');
groups python:controlPanel.getGroups('site');
getIconFor nocall:putils/getIconFor">
<div class="portletItemSingle"
tal:repeat="group groups">


<strong tal:content="group/title"
i18n:translate="">Plone Configlet Group Title</strong>
<ul class="configlets" tal:define="configlets python:controlPanel.enumConfiglets(group=group['id'])">

<li tal:repeat="configlet configlets">
<a href=""
style="display: block;"
tal:attributes="href configlet/url"
tal:condition="configlet/visible">
<img src="" alt="" tal:attributes="src python:getIconFor('controlpanel',configlet['id']);
alt configlet/description"
i18n:attributes="alt"
tal:on-error="string:" />
<tal:configletname tal:content="configlet/name"
i18n:translate=""></tal:configletname>
</a>
</li>

<li tal:condition="not:configlets" i18n:translate="label_no_panels_available">
No Preference Panels available.
</li>

</ul>

</div>
</div>

</dl>
</div>

</div>
</body>
</html>

Forgive me that Kupu WYSIWYG editor doesn't seem to preverse <td style="vertical-align: top"> attribute for table cells so that the versions could be compared line-to-line. I added some padding new lines to match cell heights.


Contribute

Something wrong or out of date? Anybody can edit or create a new article in the knowledge base. Simply create an account on this site, log in, and click the Edit button to contribute.