what's the equivalent of sequence-item and sequence-key in tal:repeat
what is the equivalent of this DTML snipplet in TAL ? <dtml-in get_all_languages> <option value="<dtml-var sequence-key>" size=40 <dtml-if "_['sequence-key'] in getLanguages()">selected</dtml-if>><dtml-var sequence-item></option> </dtml-in> -- Mit freundlichen Grüßen Joachim Schmitz -------------------------------------------------------------------- AixtraWare Ingenieurbüro für Internetanwendungen Telefon: +49-2464-8851, FAX: +49-2464-905163 --------------------------------------------------------------------
On Mon, 2003-02-10 at 10:41, Joachim Schmitz wrote:
what is the equivalent of this DTML snipplet in TAL ?
<dtml-in get_all_languages> <option value="<dtml-var sequence-key>" size=40 <dtml-if "_['sequence-key'] in getLanguages()">selected</dtml-if>><dtml-var sequence-item></option> </dtml-in>
Something like: <option size="40" tal:repeat="lang here/get_all_languages" tal:attributes="value repeat/number/index; selected python:repeat['lang'].index in \ here.getLanguages() and 'yes' or nothing" tal:content="lang">Language</option> More about this in the ZPT reference, Appendix (C) of the Zope Book: http://www.zope.org/Documentation/Books/ZopeBook/2_6Edition The sequence stuff is covered under the "repeat" statement. F.
Your solution is not the equivalent of the dtml-in here/get_all_languages returns a list of tuples: [('aa', 'Afar'), ('ab', 'Abkhazian'), ('af', 'Afrikaans'), ..... ] and in dtml-in sequence-item = Afar and sequence-key = "aa" for the first item. repeat/lang/index returns the index-number which is "0" for the first item. I just found the right solution: <td><select name="languages:list" size="5" multiple> <span tal:define="langs here/get_all_languages" tal:omit-tag=""> <option tal:repeat="lang langs" tal:attributes="value python: lang[0]; selected python: test(lang[0] in here.getLanguages(), 1,0)" tal:content="python: lang[1]">German </option> I thought I had tried that before, but apparently not. I still don't like the python: lang[1] there should be something like: repeat/lang/1 --On Montag, Februar 10, 2003 11:24:14 +0000 Felix Ulrich-Oltean <felix@chaptereight.com> wrote:
On Mon, 2003-02-10 at 10:41, Joachim Schmitz wrote:
what is the equivalent of this DTML snipplet in TAL ?
<dtml-in get_all_languages> <option value="<dtml-var sequence-key>" size=40 <dtml-if "_['sequence-key'] in getLanguages()">selected</dtml-if>><dtml-var sequence-item></option> </dtml-in>
Something like:
<option size="40" tal:repeat="lang here/get_all_languages" tal:attributes="value repeat/lang/index; selected python:repeat['lang'].index in \ here.getLanguages() and 'yes' or nothing" tal:content="lang">Language</option>
More about this in the ZPT reference, Appendix (C) of the Zope Book: http://www.zope.org/Documentation/Books/ZopeBook/2_6Edition
The sequence stuff is covered under the "repeat" statement.
F.
_______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
-- Mit freundlichen Grüßen Joachim Schmitz -------------------------------------------------------------------- AixtraWare Ingenieurbüro für Internetanwendungen Telefon: +49-2464-8851, FAX: +49-2464-905163 --------------------------------------------------------------------
oops - type in my post, it should have said: <option size="40" tal:repeat="lang here/get_all_languages" tal:attributes="value repeat/lang/index; selected python:repeat['lang'].index in \ here.getLanguages() and 'yes' or nothing" tal:content="lang">Language</option> i.e. repeat/lang/index instead of repeat/number/index. Felix.
Joachim Schmitz wrote at 2003-2-10 11:41 +0100:
what is the equivalent of this DTML snipplet in TAL ?
<dtml-in get_all_languages> <option value="<dtml-var sequence-key>" size=40 <dtml-if "_['sequence-key'] in getLanguages()">selected</dtml-if>><dtml-var sequence-item></option> </dtml-in> <tal:option repeat=opt "here/get_all_languages"> <option tal:define="key python: opt[0]; item python: opt[1]" ....
Dieter
participants (3)
-
Dieter Maurer -
Felix Ulrich-Oltean -
Joachim Schmitz