Print this article Edit this article

Zope: Creating a Folder Listing

Standard Web Servers

When a user accesses a folder on a standard web server such as Apache or IIS the web server checks for a default file such as index.html or index.cgi. When a user accesses a folder that does not contain a default file the web server will display the list of the files contained within that folder.

Zope

When a user accesses a folder on a Zope server Zope checks for a default object called index_html if it does not find the object in the current folder it moves up one level and checks for the default object in that location. The process continues until the default file is located.

Zope always finds and displays the default object, index_html. If you would like to display the list of files contained in a folder you must create a default object that displays them for you.

Creating a Folder Listing Page Template

Create a Page Template with the id index_html. Use the following Page Template code as the body of your new document.

<h2 tal:content="string:Index of ${here/title_or_id}">Title</h2>

<ul>

<tal:block tal:define="parent here/getParentNode">
<li tal:attributes="style string:list-style-image: url(/${parent/icon})">
<a style="margin-left: 5px;" href=""
tal:attributes="href parent/absolute_url">Parent Folder</a>
<span tal:condition="parent/title"
tal:content="string:( ${parent/title} )">(Title of Parent)</span>
</li>
</tal:block>

<br><br>

<tal:block tal:repeat="item here/objectValues">
<li tal:attributes="style string:list-style-image: url(/${item/icon})">
<a style="margin-left: 5px;" href=""
tal:attributes="href item/absolute_url"
tal:content="item/getId">Id of Item</a>
<span tal:condition="item/title"
tal:content="string:( ${item/title} )">(Title of Item)</span>
</li>
</tal:block>

</ul>

Creating a Folder Listing DTML Method

Create a DTML Method with the id index_html. Use the following DTML code as the body of your new document.

<h2>Index of &dtml-title_or_id;</h2>

<ul>

<dtml-with getParentNode>
<li style="list-style-image: url(/&dtml-icon;);">
<a style="margin-left: 5px;"
href="&dtml-absolute_url;">Parent Folder</a>
<dtml-if title>(<dtml-var title>)</dtml-if>
</dtml-with>

<br><br>

<dtml-in objectValues>
<li style="list-style-image: url(/&dtml-icon;);">
<a style="margin-left: 5px;"
href="&dtml-absolute_url;"><dtml-var getId></a>
<dtml-if title>(<dtml-var title>)</dtml-if>
</dtml-in>

</ul>

 

Last Modified: Dec 19, 2016 11:12 am US/Eastern
Created: Oct 25, 2007 12:42 pm GMT-4 by admin
JumpURL:


Categories