[ZDP] BackTalk to Document The Zope Book (2.5 Edition)/Appendix A: DTML Reference
nobody@nowhere.com
nobody@nowhere.com
Wed, 21 Aug 2002 10:50:53 -0400
A comment to the paragraph below was recently added via http://www.zope.org/Documentation/Books/ZopeBook/current/AppendixA.stx#4-21
---------------
These variables describe the
current item.
sequence-item -- The current item.
sequence-key -- The current key. When looping over tuples of the
form '(key,value)', the 'in' tag interprets them as
'(sequence-key, sequence-item)'.
sequence-index -- The index starting with 0 of the current item.
sequence-number -- The index starting with 1 of the current item.
sequence-roman -- The index in lowercase Roman numerals of the
current item.
sequence-Roman -- The index in uppercase Roman numerals of the
current item.
sequence-letter -- The index in lowercase letters of the current
item.
sequence-Letter -- The index in uppercase letters of the current
item.
sequence-start -- True if the current item is the first item.
sequence-end -- True if the current item is the last item.
sequence-even -- True if the index of the current item is even.
sequence-odd -- True if the index of the current item is odd.
sequence-length -- The length of the sequence.
sequence-var-*variable* -- A variable in the current item. For
example, 'sequence-var-title' is the 'title' variable of the
current item. Normally you can access these variables directly
since the current item is pushed on the DTML namespace. However
these variables can be useful when displaying previous and next
batch information.
sequence-index-*variable* -- The index of a variable of the
current item.
% rboylan - July 22, 2002 7:40 pm:
How does this work if you want to use these variables in an expression? I tried, but got errors because (I
think) - is not part of python names.
% Anonymous User - Aug. 3, 2002 4:39 pm:
rboylan, here is an example:
<dtml-if expr="_['sequence-length'] > 1">
do something..
</dtml-if>
% Anonymous User - Aug. 7, 2002 12:44 am:
When a sql search returns no results, will the value of sequence-length be zero? Whenever I run my script and
there are no results, I either get an error about sequence not being defined, or a blank screen.
% Anonymous User - Aug. 21, 2002 10:50 am:
no results? - use <dtml-else>:
<dtml-in ... >
...
<dtml-else>
...
</dtml-in>