Hi; I have this code: <dtml-if expr="number_attendees==1"> Thank you, <dtml-var first_name>. Please tell us about the attendee...<br> <br> <dtml-else> Thank you, <dtml-var first_name>. Please tell us about the attendees...<br> <br> </dtml-if> <dtml-in expr="_.range(number_attendees)"> <dtml-if expr="sequence-item==0"> <dtml-var sequence-item>st Attendee:<br> <dtml-elif expr="sequence-item==1"> <dtml-var sequence-item>nd Attendee:<br> <dtml-elif expr="sequence-item==2"> <dtml-var sequence-item>rd Attendee:<br> <dtml-else> <dtml-var sequence-item>th Attendee:<br> </dtml-if> </dtml-in> I get an error that the compiler doesn't recognize the variable *sequence*. Apparently, I'm not properly communicating to Zope that I'm trying to call the variable *sequence-item* and that it should be iterating through the loop. How do I do this correctly? TIA, BenO
Try using <dtml-if "_['sequence-item']==... instead of <dtml-if "sequence-item==.... Ben Ocean wrote:
Hi; I have this code:
<dtml-if expr="number_attendees==1"> Thank you, <dtml-var first_name>. Please tell us about the attendee...<br> <br> <dtml-else> Thank you, <dtml-var first_name>. Please tell us about the attendees...<br> <br> </dtml-if> <dtml-in expr="_.range(number_attendees)"> <dtml-if expr="sequence-item==0"> <dtml-var sequence-item>st Attendee:<br> <dtml-elif expr="sequence-item==1"> <dtml-var sequence-item>nd Attendee:<br> <dtml-elif expr="sequence-item==2"> <dtml-var sequence-item>rd Attendee:<br> <dtml-else> <dtml-var sequence-item>th Attendee:<br> </dtml-if> </dtml-in>
I get an error that the compiler doesn't recognize the variable *sequence*. Apparently, I'm not properly communicating to Zope that I'm trying to call the variable *sequence-item* and that it should be iterating through the loop. How do I do this correctly? TIA, BenO
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
-- Vincenzo Di Somma - Responsabile Ricerca e Sviluppo - Icube S.r.l. Sede: Via Ridolfi 15 - 56124 Pisa (PI), Italia E-mail: e.disomma@icube.it WWW: www.icube.it Tel: (+39) 050 97 02 07 Fax: (+39) 050 31 36 588
At 06:31 PM 10/28/01 +0100, you wrote:
Try using <dtml-if "_['sequence-item']==... instead of <dtml-if "sequence-item==....
Worked like a charm, thank you! Now, I have this code with unusual output: <dtml-if expr="number_attendees==1"> Thank you, <dtml-var first_name>. Please tell us about the attendee...<br> <br> <dtml-else> Thank you, <dtml-var first_name>. Please tell us about the attendees...<br> <br> </dtml-if> <center> <dtml-var "seminar_form_2.header()"> <table border="0"> <dtml-in expr="_.range(number_attendees)"> <dtml-if "_['sequence-item']==0"> 1st Attendee:<br> <dtml-in "seminar_form_2.get_fields()"> <dtml-let field=sequence-item> <tr> <td><dtml-var "field.get_value('title')"></td> <td><dtml-var "field.render()"></td> </tr> </dtml-let> </dtml-in><br> <br> <dtml-elif "_['sequence-item']==1"> 2nd Attendee:<br> <dtml-in "seminar_form_2.get_fields()"> <dtml-let field=sequence-item> <tr> <td><dtml-var "field.get_value('title')"></td> <td><dtml-var "field.render()"></td> </tr> </dtml-let> </dtml-in><br> <br> <dtml-elif "_['sequence-item']==2"> 3rd Attendee:<br> <dtml-in "seminar_form_2.get_fields()"> <dtml-let field=sequence-item> <tr> <td><dtml-var "field.get_value('title')"></td> <td><dtml-var "field.render()"></td> </tr> </dtml-let> </dtml-in><br> <br> <dtml-else> <dtml-var expr="_['sequence-item'] + 1">th Attendee:<br> <dtml-in "seminar_form_2.get_fields()"> <dtml-let field=sequence-item> <tr> <td><dtml-var "field.get_value('title')"></td> <td><dtml-var "field.render()"></td> </tr> </dtml-let> </dtml-in><br> <br> </dtml-if> </dtml-in> <tr> <td><input type="submit" value=" OK "></td> </tr> </table> <dtml-var "seminar_form.footer()"> </center> When number_attendees == 4 I get this output: 1st Attendee: 2nd Attendee: 3rd Attendee: 4th Attendee: <first set of fields from the form> <second set of fields from the form> <third set of fields from the form> <fourth set of fields from the form> Why don't the form fields appear in sequence under the headers instead of at the end? TIA, BenO
Ben Ocean wrote:
At 06:31 PM 10/28/01 +0100, you wrote:
Try using <dtml-if "_['sequence-item']==... instead of <dtml-if "sequence-item==....
Worked like a charm, thank you!
These days, instead of the fairly horrible hard to explain _['sequence-item'] you can use 'prefix' instead, like this. The problem is that - in Python means substraction and therefore cannot be part of a name, and due to historical reasons Zope does use the - in DTML as part of names. The prefix knob fixes this as it makes dtml-in use an underscore instead: <dtml-in something prefix="seq"> <dtml-var seq_item> </dtml-in> See also the online DTML help on 'in'. Regards, Martijn
Hi, --On Monday, October 29, 2001 13:10:24 +0100 Martijn Faassen <faassen@vet.uu.nl> wrote:
Ben Ocean wrote:
At 06:31 PM 10/28/01 +0100, you wrote:
Try using <dtml-if "_['sequence-item']==... instead of <dtml-if "sequence-item==....
Worked like a charm, thank you!
These days, instead of the fairly horrible hard to explain _['sequence-item'] you can use 'prefix' instead, like this. The problem is that - in Python means substraction and therefore cannot be part of a name, and due to historical reasons Zope does use the - in DTML as part of names. The prefix knob fixes this as it makes dtml-in use an underscore instead:
<dtml-in something prefix="seq"> <dtml-var seq_item> </dtml-in>
Ah, finally kidn of my patch is in :-) But these days one should not use something like this at all - these days are the days of Python Scripts and ZPT :-)) Regards Tino
Vincenzo Di Somma wrote:
Try using <dtml-if "_['sequence-item']==... instead of <dtml-if "sequence-item==....
I like the new "prefix" parameter of <dtml-in>. Example: <dtml-in Elvis prefix=seq> <dtml-var seq_item> <dtml-if "seq_item-1==0"> Elvis is subzero! </dtml-if> </dtml-in> I wish the old sequence-item was phased out already in favour of sequence_item... it's provoking regular repeated questions from newbies. -- Milos Prudek
An FAQ! Ben Ocean writes:
... <dtml-if expr="sequence-item==0"> ... I get an error that the compiler doesn't recognize the variable *sequence*. Inside Python expressions (you explicitly write "expr=" to remind yourself that you are using a Python expression!), '-' is not part of a name but the operator minus...
Use <dtml-if expr="_['sequence-item'] == 0"> Dieter
participants (6)
-
Ben Ocean -
Dieter Maurer -
Martijn Faassen -
Milos Prudek -
Tino Wildenhain -
Vincenzo Di Somma