I am a newbie so I must appoligize for my current lack of knowledge. Can I create a while loop in a template...
On Fri, Nov 01, 2002 at 10:23:30AM -0500, Reichman, Tal (NIH/NCI) wrote:
I am a newbie so I must appoligize for my current lack of knowledge. Can I create a while loop in a template...
You can do <dtml-in foos> to loop over a sequence in dtml, and <span tal:repeat="foo foos"> to loop over a sequence in zpt. There are no other looping constructs. So you always need to think of how to create a sequence representing the items you want to loop over. Your lack of knowledge will gradually diminish if you read the Zope book. (online version at zope.org, in the Documentation section.) -- Paul Winkler http://www.slinkp.com "Welcome to Muppet Labs, where the future is made - today!"
Reichman, Tal (NIH/NCI) wrote:
I am a newbie so I must appoligize for my current lack of knowledge. Can I create a while loop in a template...
I guess the problem is how to program a "while" loop in opposite to a "for" loop, i.e. something where You don not know in advance how many iterations it may take. The anwser is: it is not possible in a page template or DTML. Use a Script (Python) instead. E.g.: parent = context parents = [] while parent.ap_parent: parents.append(parent.getId()) parent = parent.aq_parent return parents then you can do something like <b tal:repeat="parent python:here.getParents()" tal:content="parents" /> to print all acquisition parent ids (in reverse order). Warning: script is untested, may contain syntax errors and the like. Cheers, Clemens
participants (4)
-
Chris Withers -
Clemens Robbenhaar -
Paul Winkler -
Reichman, Tal (NIH/NCI)