Adding a sort field on a view configured with the jump menu display, with grouping enabled, causes options within the select menu to appear outside of their group. Consider the example of a jump menu configured to display uid and usernames grouped by roles :
- Editors
-- 1: mike
-- 2: jim
- Authors
-- 3: bob
With no sorting active on the view, the users appear in a default order of uid (the order returned by the SQL query, I suppose), and they also appear under the correct role grouping. When one adds sorting by username on the view, the jump menu appears as such:
- Editors
-- 3: bob
-- 2: jim
- Authors
-- 1: mike
This is wrong, because "bob" is an "Author" and "mike" is an "Editor" : the select options are sorted regardless of grouping. The expected output is this :
- Editors
-- 2: jim
-- 1: mike
- Authors
-- 3: bob
I tracked this down to the foreach structures in views_plugin_style_jump_menu.inc that transform the result set into options for the select menu. Options are added to the select menu according to the result set order, regardless of groupings.
Here's a rough patch against 6.x-2.x-dev that fixes the problem.
| Comment | File | Size | Author |
|---|---|---|---|
| #9 | 747782-jumpmenu.patch | 2.09 KB | dawehner |
| #7 | 747782-jumpmenu.patch | 1.78 KB | dawehner |
| #3 | jumpmenu.patch | 3 KB | robbertnl |
| #1 | views-jump_menu_grouping_sort.patch | 1.2 KB | lavamind |
Comments
Comment #1
lavamind commentedMy first attempt to attach the file didn't seem to work out. Here's another try.
Comment #2
robbertnl commentedSubscribing
Comment #3
robbertnl commentedNew patch for Views 6.x-2.11, also removed the $grouping = url($grouping);, because i dont want to urlescape the names in the jumpmenu.
Comment #4
merlinofchaos commentedI think the url() treatment is necessary for users with clean urls off and/or users with their site not at the top level. i.e, http://www.example.com/site
I forget which.
(Also setting patches to 'needs review' is better). I should probably set this to 'needs work' because I'm very very very hesitant about removing that url().
Comment #5
lavamind commentedFrom my understanding, url() is not needed because the value it's supposed to treat simply isn't a URL, it's a string label (not an link/anchor or anything like that).
That specific issue is discussed here : #746846: Jump menu grouping label encoding
Comment #6
merlinofchaos commentedThis patch needs a reroll based on #746846: Jump menu grouping label encoding having gone in, I think.
Comment #7
dawehner#3
Please try to make the patch as easy as possible
* Removed the line breakings
* Removed the url-escaping stuff
=> The patch is the same as in #1
Comment #8
dawehnerComment #9
dawehnerHere is a patch which reuses render_grouping from the main style plugin.
It basically just removes code :)
Comment #10
merlinofchaos commentedCommitted to all branches.