[ZDP] BackTalk to Document The Zope Book (2.6 Edition)/Using Zope
Page Templates
webmaster at zope.org
webmaster at zope.org
Mon Apr 19 01:40:42 EDT 2004
A comment to the paragraph below was recently added via http://zope.org/Documentation/Books/ZopeBook/2_6Edition/ZPT.stx#2-36
---------------
Now let's add some context to your 'simple_page' template, in the
form of a list of the objects that are in the same Folder as the
template. You will make a table that has a numbered row for each
object, and columns for the id, meta-type, and title. Add these
lines to the bottom of your example template::
<table border="1" width="100%">
<tr>
<th>Number</th>
<th>Id</th>
<th>Meta-Type</th>
<th>Title</th>
</tr>
<tr tal:repeat="item container/objectValues">
<td tal:content="repeat/item/number">#</td>
<td tal:content="item/getId">Id</td>
<td tal:content="item/meta_type">Meta-Type</td>
<td tal:content="item/title">Title</td>
</tr>
</table>
% Anonymous User - Dec. 22, 2003 11:01 am:
ERROR! should read "td tal:content="item/number">#</td>
% Anonymous User - Dec. 27, 2003 12:33 am:
No, actually it should read exactly what it says there.
The explanation for why it should have the "repeat/" before it is quite bad, though.
% Anonymous User - Dec. 27, 2003 1:04 am:
Nevermind, it makes sense now:
'repeat' is a variable.
no object in the 'item' array has a 'number' attribute
so to number everything, you need to write 'repeat/number' to get the 'repeat' variable's 'number attribute'
since the tal:repeat may be nested, 'repeat/number' is ambigious in this context, so:
'repeat/list/number'
makes sense now :)
% Anonymous User - Feb. 1, 2004 2:37 am:
Yes, it does make sense if you pay attention and read below. I think that the explanation is quite
reasonable, but the distinction between "repeat/item/number" being a reference to the repetition number, and
the "item/getId" being a reference to an attribute of the item in question is not immediately clear. If you
think about it, it is, but a clear statement of the distinction would be useful.
Incidentally, an example of a nested loop may have cleared this up a little by encouraging a little bit of
intuitive learning.
% Anonymous User - Mar. 4, 2004 4:04 am:
horrible syntax :-\
% Anonymous User - Mar. 26, 2004 7:19 am:
What do you do if you have an SQL join and want to display both to the screen
e.g.
Two Tables - one called users one called items
a query that matches the id of someone who made an item vs the id and username in the user table. I cant do
<div tal:repeat="items user here/blah/method_thing"></div>
% Anonymous User - Apr. 19, 2004 1:40 am:
The syntax used for the repeat reminds me of xslt, which makes sense in this context. Not that i love the
syntax, either :-\
More information about the ZDP
mailing list