Zieve 0-1-0
Zieve is a Z-subclassable class that assists in sorting arbitrary Zope Objects in various ways. It allows developers to sort objects dynamically with primary, secondary etc keys, and provides an easy means to include dynmically sortable objects in other documents.
Here is some DTML from a DTMLMethod that uses a zclass derived from Zieve to do some sorting...
This displays a table heading with links that dynamically resort the table according to which link was clicked last. The secondary, tertiary, ...etc keys are remembered from prior clicks....
Here is an example:
<dtml-var standard_html_header> <h2><dtml-var title_or_id></h2> <!-- 'theZieve' is a Zieve or an instance of a ZClass that is subclassed from Zieve. 'name', 'color', 'birthsone', 'number' are all properties of the objects being sorted. (in this case, they are DTML Documents with properties 'name' etc....) The format 'name:format' allows you to specify a type or filter to use before comparison. In this case 'number:int' allows numerical sorting for one of the properties. --> <dtml-in "theZieve.sortObjects( theObjects = objectValues(['DTML Document']), sortOrder=REQUEST.get('sortOrder','name:color'))"> <dtml-if sequence-start> <center><table> <tr> <td><a href="&dtml-URL0;?sortOrder=name,color">name</a></td> <!-- sort by name, then color --> <td><a href="&dtml-URL0;?sortOrder=color,name">color</a></td> <!-- sort by color, then name --> <td><a href="&dtml-URL0;?sortOrder=birthstone,name,number:int">birthstone</a></td> <!-- three way sort --> <td><a href="&dtml-URL0;?sortOrder=number:int,name,color">number</a></td> <!-- nuther three way sort.. --> </tr> </dtml-if> <dtml-with sequence-item> <tr> <td><dtml-var name></td> <td><dtml-var color></td> <td><dtml-var birthstone></td> <td><dtml-var number></td> </tr> </dtml-with> <dtml-if sequence-end> </table></center> </dtml-if> <dtml-else> Sorry.. there are no objects to sort.. </dtml-in> <dtml-var standard_html_footer>
----------------------------------------------------------------------
Of course.. a Zieve is smart enough to display objects in a sortable table all on it's own, if you like... Just view it!
view