[Zope] ZPT newbie Q
06 Mar 2003 23:42:44 -0600
Don't let that lull you. ZPTs help in the separation of logic (sorting
the list) and data (the list) and presentation (showing the sorted
If you want a sorted list the best way to do it is to create a python
script to do the sorting of the list and return it.. This keeps the
tal:define/tal:conditions down to a minimum.
On Thu, 2003-03-06 at 07:47, G. Clifford Williams wrote:
> 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.
> Zope maillist - Zope@zope.org
> ** No cross posts or HTML encoding! **
> (Related lists -
> http://mail.zope.org/mailman/listinfo/zope-dev )
Interlix - President
Web Hosting - PC Service & Support
Custom Programming - Network Service & Support