[ZPT] Re: single TAL file for displaying contents!
Godefroid Chapelle
gotcha at bubblenet.be
Tue Jul 27 05:37:23 EDT 2004
vaibhav uprety wrote:
> Hi,
>
> I have a list of folders in my site in which i keep
> documents for different locations. I am using the
> following TAL code to display the files in a
> particular folder.
>
> -----------------------------------------------------
> <h4 tal:define="global file_obs
> python:here.objectValues(['File'])"
> tal:condition="not:file_obs">No Documents are
> available in this category</h4>
> <!-- If we find some, then do the table stuff -->
> <table border="1" cellpadding="5" cellspacing="0"
> tal:condition="file_obs">
> <tr>
> <th>Name</th>
> </tr>
> <tr tal:repeat="file_ob
> python:here.objectValues(['File'])">
> <td><a tal:attributes="href file_ob/absolute_url"
>
> tal:content="file_ob/title_or_id">__file_ob__title_or_id_</a>
> </td>
> </tr>
> </table>
> -------------------------------------------------------
>
> But i have to copy this code to every folder in order
> to display the file contents of that particular
> folder.
>
> Is it possible to display the contents of different
> folders by creating a single page template?
>
> Vaibhav Uprety
>
Look at the use of macros explained in
http://zope.org/Documentation/Books/ZopeBook/2_6Edition/AdvZPT.stx
Search for "metal:define-macro" or "metal:use-macro"
This way you could share the code herabove like with function calls in
programming languages.
--
Godefroid Chapelle (aka __gotcha) http://bubblenet.be
More information about the ZPT
mailing list