Set default sort in module config or elsewhere
bladernr - November 27, 2008 - 20:35
| Project: | Wishlist Module |
| Version: | 4.7.x-1.x-dev |
| Component: | User interface |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | duplicate |
Jump to:
Description
It would be exceedingly nice to add options either to the php code or to the wishlist config under SiteConfig to allow the users to set default sorts.
For example, I would really like a default sort descending based on the last updated date, so that the newest items are always displayed first. Something tells me that this is probably trivial, but I don't know enough PHP to work on it myself... yet.

#1
I fixed this for my own purposes as follows:
$header = array();if($showcolumns['wishlist_show_action'] == true) {
$header[] = array('data' => t("Action"));
}
if($showcolumns['wishlist_show_title'] == true) {
$header[] = array('data' => t("Item Name"), "field" => "n.title");
}
if($showcolumns['wishlist_show_description'] == true) {
$header[] = array('data' => t("Description"));
}
if($showcolumns['wishlist_show_priority'] == true) {
$header[] = array('data' => t("Priority"), "field" => "w.item_priority"); //, "sort" => "asc");
}
if($showcolumns['wishlist_show_cost'] == true) {
$header[] = array('data' => t("Cost"), "field" => "w.item_est_cost");
}
if($showcolumns['wishlist_show_quantity'] == true) {
$header[] = array('data' => t("Quantity"), "field" => "w.item_quantity_requested");
}
if($showcolumns['wishlist_show_urls'] == true) {
$header[] = array('data' => t("URLs"));
}
if($showcolumns['wishlist_show_updated'] == true) {
$header[] = array('data' => t("Last Updated"), "field" => "n.changed", "sort" => "desc");
}
simply adding the "sort" => "desc" to the end of the wishlist_show_updated column, and removing it from the wishlist_show_priority column.
BUT, that's a nasty hack and requires me to keep the Last Updated column visible.
So expanding a bit on the original feature request, it would be nice to have a config option that allows users to set a default sort item and sort order regardless of what columns are displayed.
That way, the user can, as in my example, opt to show it default by Last Updated in descending order (newest items first) and still allow visitors to change the sort order by any visible column once the page is rendered.
So I learned a LITTLE php today...
#2
Nicely done on getting the little PHP tweak you need.
IMHO the right answer here is something I've put off for a while - refactoring wishlist to use views for the primary list display. This way you can override the default view however you want without needing to adjust the code.
I'm going to flag this issue as "duplicate" since the views implementation will solve this problem for you when I get it done.
Scott