Example case: A contact list that's titled with a persons fullname, but I want the alpha paging to operate on the lastname (a separate CCK textfield).
A similar case is indexing on scientific name vs common name for plants/genus indexes
Currently, when the code chooses the primary grouping field ($sortfield) it just iterates and looks for the first instance of 'sortable'.
When (in a table view) I still want the title/fullname to be the first displayed column, but the lastname to be the one indexed, this doesn't work. Unless I disable sorting on title altogether (which is a reasonable option too)
However, it looks to make a little bit more sense to choose the field that's set as 'defaultsort' in the view definition. The unique 'defaultsort' setting is more explicit than the multiple 'sortable' and the fallback behaviour will continue to be the same out-of-the-box.
before:
foreach ($view->field as $field) {
if (!empty($field['sortable'])) {
$sort_field = $field['fullname'];
break;
}
}
after:
foreach ($view->field as $field) {
if (!empty($field['defaultsort'])) {
$sort_field = $field['fullname'];
break;
}
}
Does this sound reasonable?
| Comment | File | Size | Author |
|---|---|---|---|
| views_alpha_pager_alternative_key.patch | 869 bytes | dman |
Comments
Comment #1
douggreen commentedThe 'defaultsort' column simply is the default for the column, not for all of the fields. So, I don't think that this works any better than the current implementation, actually maybe a little worse. I suggest just setting the 'sortable' value for the one field you want to sort on. I think that views only uses this value when you display a table, so unless you're displaying a table, setting 'sortable' has no affect (other than to help VAP figure out which column to display as the title).
Comment #2
dman commentedOK. I thought defaultsort was for the set. My misunderstanding.
Yes, I was doing a table, but on further development it looks like having those columns within the page sortable (by anything other than the thing alpha is filtering on) is unduly messy.
Ignore me ;-)
... I was actually casting around to work towards an actual grouping view, and thought I could get alpha-pager to do the job, but I've since found views_groupby_pack so I'm patching in alpha-paging to that, rather than trying to extend alpha-paging to support grouping ;-)
It could have lived in either project, but it's looking easier to tackle from that end.
eg:
............
-A-
Apple
Avocado
-B-
Banana
-C-
Cherry
Cucumber
............