beno - wrote:
I have the following block of code:
<table tal:define="objects here/objectValues;
                   sort_on python:(('title', 'nocase', 'asc'),
                                   ('bobobase_modification_time', 'cmp', 'desc'));
                   sorted_objects python:sequence.sort(objects, sort_on);
                   start python:getattr(request, 'start', 0);
                   batch python:modules['ZTUtils'].Batch(sorted_objects, size=10, start=start);
                   previous python:batch.previous;
  <tr tal:repeat="item batch">
    <td tal:content="item/title">title</td>
    <td tal:content="item/bobobase_modification_time">
      modification date</td>  
    <td tal:content="here/author">author</td>
    <td tal:content="here/content">content</td>
that works fine. But I'd like to call the following in that table:
<td><tal:content metal:use-macro="here/XXX/macros/author"></tal:content></td>
where "XXX" is the "item" that changes each time a new item from the batch is called. In other words, there is a folder with a "batch" of files, and each file is an "item". So, since the files' titles are simply sequential numbers, it would look something like this:
<td><tal:content metal:use-macro="here/1/macros/author"></tal:content></td>
<td><tal:content metal:use-macro="here/2/macros/author"></tal:content></td>
<td><tal:content metal:use-macro="here/3/macros/author"></tal:content></td>
How do I do that? Even better, is it possible to just open up each file and read its contents??

First this is wrong:

<td><tal:content ...

If should be
<td tal:content ...

But that may be wrong in the context you've given. 

Since "do it in python" has been a theme lately, you can also return a macro from a python script like so:

Where there is an author might be a parameter.
#some python script
      return container.YourMacroFolder.someMacro[ author ]

And in your ZPT: (where is just a stub for whatever your using)

<td><span  metal:use-macro="python: context.youPythonScript(">macro goes here</span></td>

I suggest *always* doing stuff in python when things are not clear.  Then code back into your Page Templates, if desired


Zope maillist  -
**   No cross posts or HTML encoding!  **
(Related lists - )

Reply via email to