[Zope] string[0] operators in <dtml-vars>

zbir@urbanape.com zbir@urbanape.com
Wed, 18 Jul 2001 13:16:43 -0400


> 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/' }