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.

Comments

lavamind’s picture

StatusFileSize
new1.2 KB

My first attempt to attach the file didn't seem to work out. Here's another try.

robbertnl’s picture

Subscribing

robbertnl’s picture

StatusFileSize
new3 KB

New patch for Views 6.x-2.11, also removed the $grouping = url($grouping);, because i dont want to urlescape the names in the jumpmenu.

merlinofchaos’s picture

Status: Active » Needs review

I 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().

lavamind’s picture

From 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

merlinofchaos’s picture

Assigned: Unassigned » dawehner
Status: Needs review » Needs work

This patch needs a reroll based on #746846: Jump menu grouping label encoding having gone in, I think.

dawehner’s picture

Status: Needs work » Needs review
StatusFileSize
new1.78 KB

#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

dawehner’s picture

Assigned: dawehner » Unassigned
dawehner’s picture

StatusFileSize
new2.09 KB

Here is a patch which reuses render_grouping from the main style plugin.

It basically just removes code :)

merlinofchaos’s picture

Status: Needs review » Fixed

Committed to all branches.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.