Edit Zope Page Template (ZPT) content through Plone

by Mike Takahashi last modified Dec 30, 2008 03:03 PM
There may be times when you’ll want to let users edit content that resides within ZPT’s such as the footer, but without having them go through the ZMI.

This method will use Zope’s getText method to retrieve the body content of a Plone document and replace it within the body of a ZPT.

For this example, I will be using the footer ZPT located in /portal_skins/plone_templates/


In the ZMI

You will need to Customize footer and add the following code within the <div> tag:

<div id="portal-footer" metal:define-macro="portal_footer" i18n:domain="plone">

<p>
<tal:block tal:condition="exists:here/footer-content/myfooter"
tal:replace="structure here/footer-content/myfooter/getText">Footer content here</tal:block>
</p>

</div>

What we are doing here is first checking to see if the Plone page myfooter exists within folder called footer-content at the root of your Plone site (these names can be modified to anything you choose). If this check is not made, and for some reason your Plone page does not exist, Zope will display an error message. If it does exist, then it grabs the body text of the Plone page using the getText method, otherwise it displays nothing since the condition fails.

In Plone
You will need to create a new folder in Plone at the root of your site and give it the short name footer-content. Within this folder, create a new page and give it a short name of myfooter.

Now, any content that you insert into you Plone page myfooter, will be rendered by the footer ZPT of your Plone site.

This can be used in many ways, such as creating custom portlets and allowing users to edit its content through Plone.