[Zope] Sorting objectValues in ZPT ( CMF )

Heimo Laukkanen huima@fountainpark.org
Sun, 21 Apr 2002 03:41:47 +0300


This is a tip for everyone else, of they want to do sorting in ZPT. 
Atleast for me the basic CMF skin didn't sort out the folders and 
files like I wanted, so I decided to add a small sort with 
lambda-expression.

You can easily change it to sort with title or anything else.

Sorting is done in uppercase, since case doesn't matter in this case.

  <div tal:define="raw_items python: here.contentValues(
                                             filter={'Type':('Document'
                                                            , 'Image'
                                                            , 'File'
                                                            , 'News Item'
                                                            ) } );
        foobar python: raw_items.sort(lambda x, y: 
cmp(string.upper(x.getId()), string.upper(y.getId())));
        items python: auth_filter( foobar, skip='' ); ">

Hope this helps.

-huima