<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
beno - wrote:
<blockquote
cite="mid20060726220418.104.qmail@web33910.mail.mud.yahoo.com"
type="cite">
<div>Hi;</div>
<div>I have the following block of code:</div>
<div> </div>
<div><table tal:define="objects here/objectValues;<br>
sort_on python:(('title', 'nocase', 'asc'),<br>
('bobobase_modification_time',
'cmp', 'desc'));<br>
sorted_objects python:sequence.sort(objects,
sort_on);<br>
start python:getattr(request, 'start', 0);<br>
batch
python:modules['ZTUtils'].Batch(sorted_objects, size=10, start=start);<br>
previous python:batch.previous;<br>
next python:batch.next"><br>
<tr tal:repeat="item batch"><br>
<td tal:content="item/title">title</td><br>
<td tal:content="item/bobobase_modification_time"><br>
modification date</td> <br>
<td tal:content="here/author">author</td><br>
<td tal:content="here/content">content</td><br>
</tr><br>
</table><br>
</div>
<div>that works fine. But I'd like to call the following in that
table:</div>
<div> </div>
<div><td><tal:content
metal:use-macro="here/XXX/macros/author"></tal:content></td><br>
</div>
<div>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:</div>
<div> </div>
<div><td><tal:content
metal:use-macro="here/1/macros/author"></tal:content></td><br>
<td><tal:content
metal:use-macro="here/2/macros/author"></tal:content></td><br>
<td><tal:content
metal:use-macro="here/3/macros/author"></tal:content></td><br>
...</div>
</blockquote>
How do I do that? Even better, is it possible to just open up each file
and read its contents??
<blockquote
cite="mid20060726220418.104.qmail@web33910.mail.mud.yahoo.com"
type="cite">
<div>Thanks,</div>
<div>Ben</div>
<p> </p>
<hr size="1"></blockquote>
<br>
Ben,<br>
First this is wrong:<br>
<br>
<td><tal:content ...<br>
<br>
If should be<br>
<td tal:content ...<br>
<br>
But that may be wrong in the context you've given. <br>
<br>
Since "do it in python" has been a theme lately, you can also return a
macro from a python script like so:<br>
<br>
Where there is an author might be a parameter.<br>
#some python script<br>
#<br>
return container.YourMacroFolder.someMacro[ author ]<br>
-----------------------------------------------------------------------<br>
<br>
And in your ZPT: (where result.author is just a stub for whatever your
using)<br>
<br>
<td><span metal:use-macro="python:
context.youPythonScript(result.author)">macro goes
here</span></td><br>
<br>
I suggest *always* doing stuff in python when things are not clear.
Then code back into your Page Templates, if desired<br>
<br>
DAvid<br>
<br>
<br>
<br>
<br>
<br>
<br>
</body>
</html>