I can't think of an easy solution to your problem (you can't just include two versions of the dtml-in tag in a conditional; you would have to have two complete dtml-in loops, one reversed, and one not, and that's a bit ugly), however, it might help to realize that it does you no good to try to pass 'reverse' as a value of some other attribute of dtml-in. 'reverse' is an attribute in itself, and you have to state it explicitely within the tag. How about sorting your articles into another list before the <dtml-in>? I don't have time to try any of this, but you might be able to do something like <dtml-if "rev==''"> <dtml-call "REQUEST.set('sortedArticles', ObjectValues('article').sort(lambda(a,b,k=skey:a[k] < b[k])))"> <dtml-else> <dtml-call "REQUEST.set('sortedArticles', ObjectValues('article').sort(lambda(a,b,k=skey:a[k] > b[k])))"> </dtml-if> <dtml-in sortedArticles ... Caution: I just wrote that code real quick as something that might work. If you like the idea, you'll probably have to fix it somewhat. This may be more easily done in a script. Also, using this way of sorting is probably more inefficient, which matters if you have a lot of articles. Cheers, Jean
-----Original Message----- From: Benoit DOMINIAK [mailto:koubonline@hotmail.com] Sent: Friday, July 13, 2001 07:33 To: jean.lagarde@eer-rc.com Cc: zope@zope.org Subject: Re: [Zope] Choice of the sorting key of a dtml-in tag
Yes !!! That's it ! But know, how can I include reverse ;-) ? I've tryed : <a href="<dtml-var URL1>?skey=titre&rev=">Title</a> <a href="<dtml-var URL1>?skey=author&rev=">Author</a> <a href="<dtml-var URL1>?skey=bobobase_modification_time&rev= reverse">Last modification</a>
<dtml-if "REQUEST.has_key('skey')"> <dtml-else> <dtml-call "REQUEST.set('skey', 'bobobase_modification_time')"> <dtml-call "REQUEST.set('rev', ' reverse')"> </dtml-if>
<dtml-in "objectValues(['article'])" size=3 sort_expr="skey+rev" start=query_start>
But it just work with title and author (rev=none) but not with modif_time (rev=' reverse').
Can you help me ?
From: "Jean Lagarde" <jean.lagarde@eer-rc.com> To: <zope@zope.org> Subject: Re: [Zope] Choice of the sorting key of a dtml-in tag Date: Fri, 13 Jul 2001 07:20:31 -0700
Hi Benoit,
My first answer post!
Although I haven't tried that yet, my understanding is that 'sort' only accepts constants, i.e. it will interpret skey as the literal 'skey', not as its value. You need to use the undocumented 'sort_expr' instead, i.e.
<dtml-in "objectValues(['article'])" size=3 sort_expr="skey" start=query_start>
I'm not sure if you can include 'reverse' in skey; you probably have to state that separately in the dtml-in tag. [snip]