I am refering to this section of sort in draggableviews.module

/**
 * Get the draggable views weight sort of a view if there is one and return its
 * ID. If there are multiple of these sorts the first is returned.
 *
 * @param $view
 *   The view object.
 *
 * @return
 *   The ID of the sort or FALSE if there isn't one.
 */
function _draggableviews_get_draggable_sort($view) {
  foreach ($view->sort as $id => $sort) {
    if ($sort->definition['handler'] == 'draggableviews_handler_sort') {
      return $id;
    }
  }
  return FALSE;
}

This function gets call from _draggableviews_get_order_view_display. It returns a display that may or may not be the one you are looking for if you have 2 or more displays in one view.

Either, the Views UI must prevent multiple display views from happening, or add support for multiple sort displays in 1 view.

FYI fixing this issue will solve a large number of the issues in the issue queue

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

iStryker’s picture

Title: Need to add support for multiple draggable sort in one view or prevent it from happening » Need to add support for multiple draggable sort in one view display

Changing title.

This is needed for the new Group by Example Module. More information to come about this.

dobe’s picture

Where are we at with this? Is this functionality going to give the ability to group hierarchy structures (you can pretty much already group by a field)? It would be nice to be able to move a object from one group to another.

drupal_was_my_past’s picture

This issue doesn't totally make clear all the problems, so I'm not sure this is a good all-around fix. For folks who want multiple view displays in one view that create draggableviews weights, a simple fix appears to be to making settings displays set to 'self'. See attached patch.

drupal_was_my_past’s picture

Issue summary: View changes

grammer

roderik’s picture

I just encountered a problem with multiple sorts & different arguments, and thanks to this issue description I could fix it. Patch attached.

It's still pretty non-invasive: it doesn't touch any options/settings/structure. I do not know enough about Draggableviews' architecture to understand if the join-vs-sort-settings structure is OK as-is.
(And maybe you want my change to _draggableviews_get_draggable_sort() to be coded less 'general' because you don't actually want it to turn into a general utility function?)

Edit: I only changed the call from the join handler, not the one from _draggableviews_get_order_view_display(). So it doesn't solve the originally reported problem yet:

  • when building a view (display) which has multiple sorts which have different settings... it will pick those up and start sorting correctly
  • but it still does not distinguish the correct display if you call _draggableviews_get_order_view_display().
iStryker’s picture

@roderik your patch looks promising. Have not had a chance to test yet.

Its been 2 years since I created this issue...what is the use case for this again?

Also double-check...is this for multiple sorts in one view display. Or multiple sorts in a view?

roderik’s picture

It's for multiple sorts in one view display.

(I have here an existing site with a 'front end view' that groups/sorts things on 2 levels. Both these sorts are influenced by two separate back-end/draggable views. So the 2 'front end view sorts' have 2 different sets of settings (view/display/argument).

That won't work without the patch, because both sorts get the same settings.

--

But I also see my patch is incomplete. Also the use case from your original issue report is probably different.

I'll try to take some time this week to re-do parts of this code (interrelated _draggableviews_functions()) that I think I can touch without knowing too much of Draggableviews as a whole.

iStryker’s picture

Assigned: iStryker » Unassigned
iStryker’s picture

jurgenhaas’s picture

Status: Needs review » Reviewed & tested by the community

I came across this very same problem and the patch in #4 is working great.

kopeboy’s picture

But this is not allowing to sort between group by(s) right? :(

Because you closed this issue #1514116: Group by support, multiple native sorts per display in favour of this one...

NWOM’s picture

Sadly the patch does not work in the case where you have a child view embedded with Views Field View. Saving no longer works for both views. I wasn't sure if that issue belonged with this issue, so I created a new issue here: #2851094: Incompatible with Views Field View when Parent/Child are Draggable Views.

jmuzz’s picture

+1 I needed this functionality.

I had a 2 level hierarchical sort with 2 separate ordering tables, one for each level, that needed to be combined into one view.

It is much better UI in my case for each top level item to have its own table for sorting the lower level rather than trying to put the whole thing on one page, I just needed this patch to combine the results.

ChristianSanders’s picture

I too can confirm that patch #4 works a charm. I had 3 displays to show content, and 3 sort displays.

Thanks very much!

iStryker’s picture

Priority: Critical » Normal

Tested this if it broke/overridden features with the normal/order views. Nothing is overridden. Committing.

  • iStryker committed 7da4699 on 7.x-2.x authored by roderik
    Issue #1899038 by drupal_was_my_past, roderik: Need to add support for...
iStryker’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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