Skip to content

Anders Andersen

Sections
Personal tools
You are here: Home » The (aa) blog » How to list documents in a folder

How to list documents in a folder How to list documents in a folder

Document Actions
Submitted by aa. on 2004-11-14 07:20 PM. Plone
A short description on how to list the documents in a Plone folder

The following text describes how you can list the documents of the current folder (create a document that lists the title and description of the documents and includes a link to the actual document) using a Page Template. The Page Template will be the index_html file of the folder.

In this example we want to list the newest document first. The list of objects in the folder are in the reverse order. We simply reverse the list before we traverse it.

Go to the folder where you want to list the documents (you have to do this trough the ZMI interface since you can not add a Page Template in a folder from Plone). Add a Page Templet with the id index_html. Enter the following code for the Page Template, and save it. Next visit (view) of the folder should list all the documents.

<h1 tal:condition="context/title"><span tal:content="context/title">Title</span></h1>
<p tal:condition="context/description"><strong tal:content="context/description">description</strong></p>
<tal:block tal:define="doclist python:context.objectValues(); dummy python:doclist.reverse()">
  <tal:block tal:repeat="item doclist">
    <p tal:condition="python:item.meta_type=='Document'">
      <a href="" tal:attributes="href item/absolute_url" tal:content="string:${item/title}">Title of Item</a>.
      <span tal:condition="item/description" tal:content="item/description">Description of Item</span>
    </p>
  </tal:block>
</tal:block>

The listDocuments.pt is the complete page template file used in my Plone installation.

November 11 2004 (aa)

 

Powered by Plone

This site conforms to the following standards: