How to add sorting to listbuilder - Part 2
Jade kindly brought everything together on how to work with the list builder that is generated from a database query
This little how to describes how to sort lists that are not database driven
Adding orderby to ad_page_contract
ad_page_contract {
} {
orderby:optional
}
Indicating which colums should get sorted
Add the switch-orderby to you list builder definition:
-orderby {
element_name {orderby column_name}
...
}
Sort the multirow
if { [exists_and_not_null orderby] } {
regexp {([^,]*),(.*)} $orderby match column order
if { $order == "asc" } {
template::multirow sort emails -increasing $column
} elseif { $order == "desc" } {
template::multirow sort emails -decreasing $column
}
}
Note: Behind the scenes lsort is used. You can add any swith that lsort understands.
References
- http://rubick.com:8002/openacs/list-builder
- http://openacs.org/forums/message-view?message_id=115009
- /api-doc/proc-view?proc=template::multirow
Request notifications