I created a very simple DV with the option of saving the weight using full arguments to avoid sorts interfering with each other. However, after saving the view for a couple of different arguments and veiwing the results it was clear the argument was not being used to differentitate which nodes to view in a sort. There were apparent duplicates.

I tracked the problem down to the fact that the options item 'draggableviews_setting_view' was empty rather than holding the default value 'self' as the code suggested. This meant that the join handler didn't add any of the join conditions to identify this particular sort in the draggableviews_structure.

The problem seems to be caused in the draggableviews_handler_sort.inc code where the default 'self' should be set. However in this simple case of only one view with a sort the default 'self' is stored in $options but then the form element value is set to $this->options['draggableviews_setting_view'], the previous value of this option which was empty. So the default value is never set.

The code:

$form['draggableviews_setting_view'] = array(
    '#type' => 'value',
    '#value' => $this->options['draggableviews_setting_view'],
 );

should be changed to:

isset($this->options['draggableviews_setting_view']) ? $options = $this->options['draggableviews_setting_view']: $options = 'self';
$form['draggableviews_setting_view'] = array(
    '#type' => 'value',
    '#value' => $options,
);

or something similar so if the previous value is empty the default is used.

Comments

jkempff’s picture

THANK YOU!

Works like a charm for me!

robertom’s picture

I have same problem and the patch fix it also for me.

After apply the patch is needed to resave (apply on views UI) "draggableviews sort criteria" on views with draggableviews field

robertom’s picture

Status: Active » Needs review
nonzero’s picture

Status: Needs review » Needs work

The patch at comment #2 doesn't seem to include the first edit to the file by dippers:

isset($this->options['draggableviews_setting_view']) ? $options = $this->options['draggableviews_setting_view']: $options = 'self';
nonzero’s picture

Status: Needs work » Needs review
StatusFileSize
new622 bytes

Added the line above with a slight modification.

robertom’s picture

The patch at comment #2 doesn't seem to include the first edit to the file by dippers:

isset($this->options['draggableviews_setting_view']) ? $options = $this->options['draggableviews_setting_view']: $options = 'self';

Ops... I first fixed this bug for my own use, and after I have found this issue, so... I haven't saw this snippet of code.

When is needed this snippet of code?

On comment say:

Check whether current views display doesn't have draggableviews field.
If it has, it means that this is setting view so we should set option draggableviews_setting_view to 'self'

and $option is initialized with 'self' and never changed for setting view...

bryancasler’s picture

Status: Needs review » Reviewed & tested by the community

#5 worked perfectly for me

ygerasimov’s picture

Status: Reviewed & tested by the community » Fixed

Committed. Thanks!

Status: Fixed » Closed (fixed)

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

off’s picture

Thank you!