I have a bunch of "Item" nodes, each of which has a node reference field, allowing it to reference one or more "Category" nodes. The "Category" nodes are ordered with a draggableview. I created another view that lists all "Item" nodes, grouped by the category they reference. I added a relationship to this view on the node reference field, so I could sort the groups of items based on the order of their parent "Category" nodes. Ultimately I end up with something like this:

Category 1
* Item 1
* Item 2
Category 2
* Item 3
* Item 4
Category 3
* Item 5
* Item 6

Everything seemed to be working fine, but when I came back to that same view later in my development process, I noticed that many of my items were being duplicated, leaving me with something like this:

Category 1
* Item 1
* Item 2
* Item 1
* Item 2
Category 2
* Item 3
* Item 4
Category 3
* Item 5
* Item 6
* Item 5
* Item 6

After much banging of my head against the wall, I finally figured out why the duplication is occurring, but I have no idea how to fix it. Sometime after creating this view of "Item" nodes, I created another draggableview to order some taxonomy terms. It turns out that draggableviews stores term IDs in the draggableviews_structure.nid field, right along side node IDs and doesn't do anything to differentiate between nodes and terms. So any time the nid of a "Category" node was the same as the tid of a taxonomy term, all the items linked to that category would show up twice in the list. Once based on the "Category" node's entry in draggableviews_structure and once for the term's entry in that same table.

Inorder to remedy this situation in DraggableViews itself, perhaps the views sort and field handlers could be modified, allowing users to indicate which draggableview they'd like to reference. This could then add a term to the views query allowing it to filter on the draggableviews_structure.view_name field, as well as the nid, thus preventing any duplication.

Comments

jstoller’s picture

As a temporary fix, I added the following function to my module:

<?php

/**
 * Implementation of hook_views_pre_execute()
 * 
 * Fix DraggableView bug.
 */
function MY_MODULE_views_pre_execute(&$view) {
  if ($view->name == 'items') {
    $subject = $view->build_info['query'];
    $search = 'AND node_node_data_field_category_draggableviews_structure_node0.delta = 0';
    $replace = 'AND node_node_data_field_category_draggableviews_structure_node0.delta = 0 AND node_node_data_field_category_draggableviews_structure_node0.view_name = "categories"';
    $view->build_info['query'] = str_replace($search, $replace, $subject);
  }
}

?>
iStryker’s picture

Status: Active » Closed (won't fix)

I do not think taxonomy was support in 6.x.

6.x in now unsupport. Closing this issue.