[Zope] ZPT newbie Q

G. Clifford Williams gcw-python@rezidew.net
Thu, 6 Mar 2003 07:47:39 -0600


hrmm looks like my enthusiasm for ZPT has hit a lull. Thanks for the help, 
It's greatly appreciated.


On Thursday 06 March 2003 01:47 am, you wrote:
> G. wrote on Wednesday, March 5, 2003, 10:38:58 PM:
> > I'd like to generate a list of links that does not include the index_html
> > page.
>
> Notice the tal:condition="python:item.getId()<>'index_html'" below.
> Also notice the general use of object/title_or_id instead of just
> object/title.
>
> > My second question is: Is there any way to sort the list that's
> > generated?
>
> Sort is a bit awkward inside page templates. The sort part of this
> code is basically ripped from the API reference in the Zope Book.
> It does an insensitive sort on the title, then date.
>
>   <font size=+1 tal:content="template/title_or_id">Title</font>
>   <UL tal:condition="container/objectValues"
>       tal:define="objects here/objectValues;
>                   sort_on python:(('title', 'nocase', 'asc'),
>                                   ('bobobase_modification_time', 'cmp',
> 'desc')); sorted_objects python:sequence.sort(objects, sort_on)"> <LI
> tal:repeat="item sorted_objects">
>           <span tal:define="i item/title_or_id"
>                 tal:condition="python:item.getId()<>'index_html'"
>                 tal:replace="i">ITEM</span>
>     </LI>
>   </UL>
>
> If you're wanting to do anything very complicated with lists, i'd just
> write a python script to generate the list the way you want it, then
> loop over that.