Sevi - this module rocks :)

Question: How would you recommend we set up the default value for the integer CCK field?

Whenever I add new content, the Draggable Views errors "Detected order collisions", and then repairs successfully. So once I hit "refresh", everything looks perfect.

It seems like the only way to do this is for the default value for the integer CCK fields to be set as the next highest integer. But that gets more complicated when hierarchies are implemented.

How should I proceed? Is there a way for me to rebuild the hierarchy prior to the view loading so that I don't have to hit refresh to see the fixed collisions? Or maybe rebuild it inside a hook_node_api() call when the content is being saved, so that the hierarchy is always up to date?

Thanks again for your awesome, awesome, awesome module!

CommentFileSizeAuthor
#3 draggableviews.inc_.patch2.68 KBsevi

Comments

raspberryman’s picture

Title: What should we use for the integer default value? » Cannot create structure manually / cannot work with existing structures
Category: support » bug

Steps to reproduce:

1) I create mynode 1, mynode 2, and mynode 3
2) Without using Draggable Views, I set mynode 2 and mynode 3 to have mynode 1 as parent (just using node edit form)
3) I manually set the CCK integer fields for weights (using the same weight values as would have been created by Draggable Views)
4) After 1-3 is done, only then do I load Draggable Views, and it "Detected order collisions" and repairs successfully. However, it does not retain the CCK parent and resets it to none.

My guess... and I am likely wrong... is that the structure is not saved to the DB when I create the structure manually before loading Draggable Views, so it has to rebuild. Am I right? If that is the case, is there a way to retain the CCK nodereference?

Cheers,

-Tony

raspberryman’s picture

Category: bug » feature

After some more experimentation, here are my conclusions:

When using hierarchies, Draggable Views needs default values for the integer fields used for ordering. It doesn't like empty fields, especially when hierarchies are involved.

My solution is to create a PHP default value for the integer fields. The PHP runs a SELECT MAX(my_integer_field) query to pull the latest value, then adds +1 to that result. That way, I know that the default integer is not already being used. I run this for each of my ordering fields. Also - the default integer is always 2 or above, as 1 seems to be reserved by Draggable Views.

It would be very nice if Draggable Views would accept empty ordering fields, even within hierarchies, and simply add the new node to the end of the list (even the end of a list of children). Maybe I should change this thread to Feature Request just for that :)

sevi’s picture

StatusFileSize
new2.68 KB

The attached patch puts new nodes (or nodes with invalid order-values) to the very end of the list of nodes to be processed. Thus new nodes will have the highest order-value at all.
If this works I'll make this an option (..and let the user choose whether to default new nodes on top or on bottom).

Please try,

greetings,
sevi

sevi’s picture

Status: Active » Fixed

seems to be fixed

Status: Fixed » Closed (fixed)

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