Hi, This is a newbie question but I haven't been able to find an aswer either at the ZopeBook nor querying Google. How do I filter objects in the <dtml-in> tag based on some object property? For instance, I want to loop over a set of objects in current directory, like, say all DTML Document objects that have an id (name) that begins with "tab-". I have tried with: <dtml-in expr="objectValues('DTML Document')"> <dtml-if expr="_.string.find(id, 'tab-') == 0"> <p>Object title: &dtml-title;</p> </dtml-if> </dtml-in> But I get a Error Type: AttributeError Error Value: namefind error. Help or pointers to docs appreciated. Thanks for your time!! /Rafa -- Rafael Cordones Marcos rcm@sasaska.net http://www.sasaska.net
Rafael Cordones Marcos wrote at 2003-6-16 19:14 +0200:
... How do I filter objects in the <dtml-in> tag based on some object property?
For instance, I want to loop over a set of objects in current directory, like, say all DTML Document objects that have an id (name) that begins with "tab-".
I have tried with:
<dtml-in expr="objectValues('DTML Document')"> <dtml-if expr="_.string.find(id, 'tab-') == 0"> <p>Object title: &dtml-title;</p> </dtml-if> </dtml-in>
But I get a
Error Type: AttributeError Error Value: namefind
"id" is a dangerous name. Sometimes, it is a string and sometimes (in your case) it is a method. Always use "getId" (which is a method). Try: <dtml-if expr="getId().startswith('tab-')"> ... </dtml-if> Dieter
participants (2)
-
Dieter Maurer -
Rafael Cordones Marcos