diff --git a/draggableviews.module b/draggableviews.module index 83d1de7..9a5c872 100755 --- a/draggableviews.module +++ b/draggableviews.module @@ -529,7 +529,10 @@ function draggableviews_draggableviews_style_plugin_form_alter(&$form, $form_sta $form['draggableviews_arguments'] = array( '#type' => 'checkboxes', '#name' => 'draggableviews_arguments', - '#options' => array('use_args' => t('Use arguments as well as view ID to order nodes.')), + '#options' => array( + 'use_arg' => t('Use first argument as well as view ID to order nodes.'), + 'use_args' => t('Use all arguments as well as view ID to order nodes.'), + ), '#description' => t('If checked, nodes can be reordered for any set of views arguments. Use with care: If you have many combinations of arguments, your database could become very large.'), '#default_value' => $current['draggableviews_arguments'], ); diff --git a/implementations/draggableviews_handler_native.inc b/implementations/draggableviews_handler_native.inc index a3af963..d0ccc6e 100644 --- a/implementations/draggableviews_handler_native.inc +++ b/implementations/draggableviews_handler_native.inc @@ -22,6 +22,10 @@ class draggableviews_handler_native extends draggableviews_handler { $args = implode('/', $this->view->args); } + if (!empty($this->view->style_plugin->options['draggableviews_arguments']['use_arg'])) { + $args = $this->view->args[0]; + } + db_query("DELETE FROM {draggableviews_structure} WHERE view_name='%s' AND nid=%d AND delta=%d AND args='%s'", $this->view->name, $nid, $this->delta, $args); db_query("INSERT INTO {draggableviews_structure}(view_name, nid, delta, value, args) VALUES('%s', %d, %d, %d, '%s')", $this->view->name, $nid, $this->delta, $value, $args); } diff --git a/views/draggableviews.views.inc b/views/draggableviews.views.inc index df94fae..56fa80d 100755 --- a/views/draggableviews.views.inc +++ b/views/draggableviews.views.inc @@ -146,6 +146,30 @@ function draggableviews_views_query_alter(&$view, &$query) { } } + // This chunk of code is just a clone of the chunk above, but applied towards + // the setting 'use_arg' instead of 'use_args'. + // I guess it might be a good idea to use values -1, 0, 1 instead, sometime in + // the future. + $use_arg = FALSE; + if (isset($view->style_plugin->options['draggableviews_arguments']['use_arg'])) { + $use_arg = !empty($view->style_plugin->options['draggableviews_arguments']['use_arg']); + } + else { + foreach ($view->display AS $display_id => $display) { + if (isset($display->display_options['style_plugin'])) { + $display_options = $display->display_options; + // We don't care about the fact that displays probably don't contain + // all their information because of inheritance of the default display. + // We'll check the default display anyway. + if ($display_options['style_plugin'] == 'draggabletable') { + if (!empty($display_options['style_options']['draggableviews_arguments']['use_arg'])) { + $use_arg = TRUE; + } + } + } + } + } + for ($i = 0; $i < 2; $i++) { if (isset($query->table_queue['draggableviews_structure_'. $view->base_table . $i])) { $query->table_queue['draggableviews_structure_'. $view->base_table . $i]['join']->extra[] = array( @@ -159,6 +183,11 @@ function draggableviews_views_query_alter(&$view, &$query) { $args = implode('/', $view->args); } } + if ($use_arg) { + if (!empty($view->args)) { + $args = $view->args[0]; + } + } $query->table_queue['draggableviews_structure_'. $view->base_table . $i]['join']->extra[] = array( 'field' => 'args', 'operator' => '=',