I have an issue with using a draggable view to display the sort order of nodes referenced by a given node. Details as follows:

Node type contains a nodereference field to represent a collection of nodes. I'm doing this to take advantage of the excellent noderelationships module to quickly reference multiple existing nodes in a user friendly interface. It also allows nodes to belong to multiple structures, which is a major requirement in terms of content re-use.

I've setup a tabbed view including the "collection" nodereference field as a relationship, and the node:ID as an argument. This works well and displays all the referenced nodes by title in a standard table. It even displays all the node titles from the collection reference for a given node:ID in a draggableview, but this is where the fun stops.

While the draggableview successfully executes the query and displays the correct list of nodes, it does not save any weight or parent information using the native handler. I can rearrange the order and depth, but upon clicking save, the node order is not changed and reverts to the standard order of the "collection" nodereference field. Further, when I attempt to subordinate a node within the view, the node is correctly indented in the table, but the collapse arrow does not appear as it should.

Effectively, I'm trying to limit the nodes displayed in a draggableview by using a nodereference field as a "collector". It's not working, and I'm sad. I've eliminated the possibility of the problem being a tabbed page view, as I can successfully build and save draggableviews without the nodereference relationship. So I'm guessing that somehow draggableviews is not respecting the relationship. Any ideas?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

sevi’s picture

Can you make a screenshot of your draggableviews/views config.. (the exported view would also do it)

looplog’s picture

FileSize
5.93 KB

views export attached.

sevi’s picture

I read it a few times but I didn't really get it yet. I think I've to try it on my machine.

Maybe you should use the relationship for the "DraggableViews: Order" field too (for both field and order field).
Does that make sense? :) I'll think about that tomorrow.

mmilo’s picture

FileSize
6.2 KB

Is there an update this? I can't seem to get DraggableViews to respect relationships either. I am using a CCK field for the handler.

I've disabled the pager and set 'items to display' to unlimited.

I also get the infinite "The structure was broken. It has been repaired." message showing.

Attached is my view. Thanks!

chaps2’s picture

Status: Active » Needs work
FileSize
2.54 KB

I had the same problem which appears to be with the use of $view->base_field in the _draggableviews_info method of draggableviews.inc on which to key the order info.

Here's a very tentative patch that checks the order field for a relationship and uses the related field to key the order info instead. I say tentative because I couldn't find a way to easily get the related field alias from the relationship object and suspect that there are more complex relationships for which this would not work.

Hopefully though this is a start in the right direction.

chaps2’s picture

On closer inspection the above patch doesn't save the order correctly. This one does:

obrienmd’s picture

Would be very interested in this, even possibly willing to sponsor a bounty. I couldn't get patch in #6 to work (applied, but gave me errors in Drupal - "The structure was broken. It has been repaired.")...

Our use case: We have a user list view, with relationship to a content profile node type. The order target is a CCK field in the content profile, so setting up draggable views in this view does not work, as the relationship is not respected. The draggable UI shows up fine, but changes are not committed to the CCK field in the content profile node.

Jhef.Vicedo’s picture

Version: 6.x-3.x-dev » 6.x-3.4
Status: Needs work » Needs review
FileSize
4.8 KB

Found a line that patch on #6 did not fix. So here's another patch based from it.

obrienmd’s picture

Status: Needs review » Needs work

Using views 6.x-2.11 and #8 patch against draggableviews 6.x-3.4, my user relationship ordering view does not work. Mine may be an odd case, though, as it's a user-based view (not a node one), where I'm trying to manage a CCK ordering field in a content profile (using relationship). Still get "The structure was broken. It has been repaired.".

heatherann’s picture

FileSize
13.27 KB

I'm not sure if this is the right thread to be posting in, but I'm having a similar issue.

I'm developing a book without using the book module. I have the following content types:

Book
Part
Chapter
Section

The last three types have a Nodereference field called "Parent" which can only refer to a node that belongs to the next type up (i.e. Chapters can refer to Parts, Sections can refer to Chapters).

My Draggable View is set so the Order is based on the DV order and the Parent is set by this "Parent" Nodereference field. It displays fine, as you can see in the attached screenshot. The hierarchy is showing up.

Now, when I go to reorder things, I run into issues. I can switch the order of the two chapters you see in the screenshot, and that saves fine. But I can't move the Section from one chapter to another. That resets back to what it was before when I save.

Itangalo’s picture

I'm having similar difficulties with relationships when fiddling with some functions emulating Drupal books (see #995370: Want the ability to create multiple outlines/maps if you're interested in details).

I think the approach above would set weight and parents for the referenced node in itself, which may cause problems if the same node is used in another list in the draggable view. It might be mitigated by using the option Use arguments as well as view ID to order nodes, but that relies on you using an argument for telling 'different' lists apart.

Ideally, the weights and parents would be saved to the reference fields and not the nodes. But I guess that is really tricky – even if weights could be mapped against delta value there is no native way of storing parents.

@heatherann: I think your problem is of a different sort, and risk being forgotten unless you post a new issue about it.

Itangalo’s picture

FileSize
3.78 KB

I successfully tried a workaround that allows DraggableViews being used on referenced nodes. It is explained in a quick screencast at http://vimeo.com/18442914.

To use this I had to make a small patch to DraggableViews, allowing using only the *first* argument + view ID to manage ordering. The patch should probably be rewritten before it eventually might be incorporated in DraggableViews, but it could still be useful.

The patch applies to DraggableViews 3.5, since that version was newer than the dev(!).

Cheers!
//Johan Falk, NodeOne, Sweden

jdln’s picture

Im trying to follow the screencast. As soon as I add the global argument of null I stop getting any results. My draggable view is a block, will your method only work if the view display is a page?

UPDATE. Is the custom PHP code a necessary part of the workaround? Im using node ID from url at the moment.

Thanks

Itangalo’s picture

There is since like 24 hours a much sweeter approach to this!
Check out the sandbox project "Referenced nodes in Views": http://drupal.org/sandbox/itangalo/1083254

Cheers

kunago’s picture

FileSize
16.45 KB
64.98 KB
23.35 KB

Since I really need the possibility to sort referenced nodes I tried to implement the patch provided in #8, this time for D7 though.
It seemed to work at the beginning just fine. I am able to sort nodes and the weights are being saved in the database properly. More precisely, I have photos entities that are referencing to places entities. Those photos, however, reference often to more than one place so I am using the option "Use arguments as well as view ID to order nodes" to achieve the desired behavior.

It worked until there were two or more records for a photo. For instance, if a photo gets 3 DB records for 3 different places, I see the photo 3 times in each draggableview view where that photo should appear.

It seems to be caused by the draggableview sorting field because the case result appears also on non-draggableview pages that uses the same sort option.

docwilmot’s picture

any news on this? havent tried Itangalo's module yet, but its still sandboxed. is that the only way? have spent a day trying to get a sortable list of referenced nodes before finding this issue.

iStryker’s picture

Status: Needs work » Closed (won't fix)

Thanks for all you help on this issue however Drupal 6.x is no longer supported. Closing issue.