[Zope] ZPT help

J Cameron Cooper jccooper at jcameroncooper.com
Thu Aug 28 20:47:48 EDT 2003


><!-- begin template -->
><div>
>  <!-- common top-nav links go here -->
></div>
>
><div tal:content="structure here/content">
>  The actual page content will be rendered here
></div>
>
><div metal:use-macro="here/right_nav/macros/main">
>  This will be replaced with the right nav macro which you
>  can override per folder.
></div>
><!-- end template -->
>
>...
>
>Now create the right nav for the products/ folder.
>To do this, just create a ZPT called products/right_nav.
>It should look something like:
>
><!-- begin template -->
><html>
><body>
><div metal:define-macro="main">
>  <a href="/products/product-1"> Product 1 </a>
>  ...
></div>
></body>
></html>
><!-- end template -->
>
If you wanted dynamic links instead of static, you could use something like this in place of the macro in the template::

<tal:block repeat="link here/links">
<a href="." tal:content="link/title_or_id" tal:attributes="href link/id">link title</a>
</tal:block>

The 'links' above is a python script that supplies the objects that are valid links. It could be as simple as 'return context.objectValues()' to return all the contents of the folder you are calling the method in. If that folder might have other contents (like 'content'), it might be easiest to make a further subfolder (say 'publish') and use 'return context.publish.objectValues()'. Of course, you could always filter on meta_type like 'return context.objectValues('File')' or any other scheme.

	--jcc






More information about the Zope mailing list