Drupal 7.14,
Views 7.x-3.3
Draggable views 7.x-2.0

I'm using draggable views to sort nodes in view with 2 taxonomy arguments passed - e.g. view_name/taxonomy1/taxonomy2.
When I started to save the row weights with the help of "settings" view (the view you can order the nodes) - the nodes started to double and triple.
I analysed the sql query and find out that there is no arguments used for filtering the node weights in the view when joining the draggable_views table to the main query - so this is the reason of why the nodes are appearing more then one time in the settings view. The part of the query looks like this - and we see that there is no filtering applied:

LEFT JOIN {draggableviews_structure} draggableviews_structure ON node.nid = draggableviews_structure.entity_id

instead of:

LEFT JOIN {draggableviews_structure} draggableviews_structure ON node.nid = draggableviews_structure.entity_id AND draggableviews_structure.view_name = 'new_technic_grid_view' AND draggableviews_structure.view_display = 'page_2' AND draggableviews_structure.args = '[\"19\",\"26\"]'

I digged into the code and wrote a few lines which I beleive are not correct, because cause of the problem is somewhere in saving the draggableviews_setting_view setting - which causes also the ugly warning:

Warning: Invalid argument supplied for foreach() in sites\all\modules\views\plugins\views_plugin_display.inc on line 274

I patched the file draggableviews_join_handler.inc at line 39 which seams to be solved the issue in my case:

//my code
    if(!isset($view_query->view->sort[$weight_key]->options['draggableviews_setting_view']) ||
        empty($view_query->view->sort[$weight_key]->options['draggableviews_setting_view'])) {
      $view_query->view->sort[$weight_key]->options['draggableviews_setting_view'] = 'self';
    }
//end of my code
   
    if (!empty($view_query->view->sort[$weight_key]->options['draggableviews_setting_view'])) {

I attached the screenshot of the view and the problem which couses the warning.

CommentFileSizeAuthor
Dviews-2-warning.png113.79 KBNor4a
Dviews-1.png68.55 KBNor4a
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

OFF’s picture

Same issue

ygerasimov’s picture

Status: Active » Fixed

Very good point! Thank you for this report.

The problem was if you add Sort field Draggableviews Weight BUT do not click Save settings option 'draggableviews_setting_view' don't get saved. And by default (in draggableviews_handler_sort::option_definition()) it is set to NULL. So naturally in check

if (!empty($view_query->view->sort[$weight_key]->options['draggableviews_setting_view'])) {
}

code is not executed so arguments condition is not added.

I have changed default value to 'self' and now everything looks to be working. Commit d7ca739

Please test and reopen this issue if you still have problems here.

Status: Fixed » Closed (fixed)

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