First time attempting to submit a patch, so please forgive me if I'm doing this wrong. I searched but wasn't able to find a duplicate issue.

Issue:
I have a draggableview to order items on my site's homepage. The view filter only shows nodes that are promoted to the front page, and the sort is set to draggableview.

I have another view to show nodes on my site's homepage. The sort uses the above draggableview first, then post date (desc).

The idea is for my site's editors to promote to the front page those nodes they wish to sort, for those nodes to appear first in the correct custom sorted order, and then for all other nodes to appear below these nodes in reverse chronological order.

The problem occurs when a node is demoted from the front page. When I demote a node, it no longer meets the filter criteria set in the draggableview; however, because the draggableview has not been re-ordered, that node's weight is retained in draggableviews_structure.

The result is that nodes that are not promoted to the front page do not appear in reverse chronological order as they should, because they still retain their weights in the draggableviews_structure table.

Cause:
The set() function in draggableviews_handler_native.inc (line 21) takes new form information, clears out the previous order record, and replaces it with the new order record. However, because it only loops through entities that are in the new order (line 49), it misses entities that were in the old order but no longer meet filter criteria for the new order.

Solution:
What I propose is to take the deletion of the previous order record out of the for loop (line 49) and delete every record that matches view_name, view_display, and args. This will remove all entities previously ordered in this particular instance, regardless of whether or not they meet the filter criteria.

Possible issues with this solution:

  • If there's a use case where you actually need entities removed from the draggable view to retain their old order information, this will get rid of that
  • ... ?
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

vbharathan created an issue. See original summary.

vbharathan’s picture