string[0] operators in <dtml-vars>
I'm trying to produce the following results in an HTML form list/menu where: <dtml-var name> - <dtml-var descirption> gives me something like: [ http://www.zope.org - the official Zope homepage ] I only want the first few characters of the description though i.e. [ http://www.zope.org - the official... ] I'm having a little problem getting the desired results though as I get an *Error Type: KeyError* *Error Value: description[0]* <dtml-in expr="getLinks(category=_['name'])"> <option value="<dtml-var url>"><dtml-var name> - <dtml-var expr="_['description[0]']"> <-- problem here obviously <dtml-var expr="_['description[1]']"> | | <dtml-var expr="_['description[9]']">... </option> </dtml-in> Could someone point me in the right direction? Thanks in advance :) Lee
I'm trying to produce the following results in an HTML form list/menu where: <dtml-var name> - <dtml-var descirption> gives me something like: [ http://www.zope.org - the official Zope homepage ]
I only want the first few characters of the description though i.e. [ http://www.zope.org - the official... ]
I'm having a little problem getting the desired results though as I get an *Error Type: KeyError* *Error Value: description[0]*
<dtml-in expr="getLinks(category=_['name'])"> <option value="<dtml-var url>"><dtml-var name> - <dtml-var expr="_['description[0]']"> <-- problem here obviously <dtml-var expr="_['description[1]']"> | | <dtml-var expr="_['description[9]']">... </option> </dtml-in>
Could someone point me in the right direction?
Well, how about <dtml-var description size='10'> That'll automatically truncate anything longer... and give you the '...' at the end ( unless you specify your own etc='blah blah blah' attribute ) me = { 'name' : 'Zachery Bir', 'email' : 'zbir@urbanape.com', 'voice' : '(804) 353-3742', 'url' : 'http://www.urbanape.com/' }
Hi Lee,
From the Zope Book, Appendix A - DTML Reference: http://www.zope.org/Members/michel/ZB/AppendixA.dtml
" etc=arg Specifies a string to add to the end of a string which has been truncated (by setting the size attribute listed above). By default, this is ... Examples [snip] Truncation: <dtml-var colors size=10 etc=", etc."> will produce the following output if colors is the string 'red yellow green': red yellow, etc. " Will that do what you are looking for? Eric.
-----Original Message----- <dtml-in expr="getLinks(category=_['name'])"> <option value="<dtml-var url>"><dtml-var name> - <dtml-var expr="_['description[0]']"> <-- problem here obviously <dtml-var expr="_['description[1]']"> | | <dtml-var expr="_['description[9]']">... </option> </dtml-in>
participants (3)
-
Eric Walstad -
Lee -
zbir@urbanape.com