How To use plone folders from navigation slot in ZPT |
![]() |
Created by dpetersen . Last modified 2003-11-01 10:57:11. |
This document describes how to fill a index_html page with subfolders from the current directory using plone publishing logic.
|
IntroductionIf you dont want the default plone folder_listing to show subfolders and documents you just can create a static index_html plone document and manually add links from there. But this can be a bit of a hassle to maintain, if your site is very dynamic. Because a folder can have a description property it makes sense to use that description in index_html. There are several ways to access folder id, title and description. The Zope Way You can retrieve a list of folders from the current folder like this The Plone Way So we use the Plone internal function navigation_tree_builder to retrieve the same list of subfolders as the navigation slot shows: If the current folder has a string property folderimage index_html will insert an image at Here is the index_html ZPT in full length : <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US" metal:use-macro="here/main_template/macros/master" i18n:domain="plone"> <body> <!-- ##### define 'listingimage' for folder list below in line 12 --> <div metal:fill-slot="main" tal:define="listingimage string:images/dotimage; tree python:here.navigation_tree_builder(here,showFolderishSiblingsOnly=1,includeTop=0);"> <div class="contentHeader"> <h1 tal:content="here/title_or_id">Title or id</h1> </div> <div class="description" tal:content="structure here/Description"> description </div> <!-- ##### BEGIN CUSTOM CONTENT ------------------------------------------- --> <table width="90%" cellspacing="5" border="0"> <tr> <td width="25%" align="left" valign="top"> <div tal:condition="exists:here/folderimage"> <!-- ### get 'folderimage' from Folder Properties --> <img src="dummy.img" tal:attributes="src string:${here/folderimage}" width="175" height="175"> </div> </td> <td width="5%"> </td> <td width="70%" align="left" valign="top"> <b><font size="-1" color="#686667"> Bitte wählen Sie einen Menüpunkt aus oder benutzen Sie die Navigationsleiste </font></b><br><br> <table width="100%" border="0"> <div tal:repeat="folderobj tree/list"> <!-- ### BEGIN FOLDER LOOP --- --> <span tal:define="folder python:folderobj['object'];" tal:on-error="structure string:<!--Error in Navigation loop!!-->"> <tr><ul> <td width="15" valign="top"> <img src="dummy.img" tal:attributes="src listingimage" width="10" height="10"> </td> <td valign="top"><a href="folder" tal:attributes="href folder/absolute_url" tal:content="folder/title">folder title</a> <font size="-2"><span tal:replace="folder/description">description</span></font> </td> </ul></tr> </span> </div> <!-- ### END FOLDER LOOP ------ --> </table> </td> </tr> </table> <!-- ##### END CUSTOM CONTENT --------------------------------------------- --> </div> </body> </html> |
Comment
Necessary change for more recent Zope versions (like 2.7.1)
Posted by:
tesmer
at
2004-07-12
In more recent Zope versions the line
tree python:here.navigation_tree_builder(here,showFolderishSiblingsOnly=1,includeTop=0);">
should be replaced by
tree python:here.plone_utils.createNavigationTreeBuilder(here,showFolderishSiblingsOnly=1,includeTop=0);">
to make the example index_html
work.