- 🇦🇺Australia stephenrodrigo@yahoo.com Melbourne
The, problem for this is the ARGS column in the draggableviews_structure table. In Draggable views 8.X versions, the arguments were saved in the ARGS column. Therefore, sorting were based on arguments of the URLs. This was working perfectly with Drupal 7.
When you inspect the draggableviews_views_submit hook. You will see the $view_args will be set from $view->args
$view_args = !empty($view->args) ? json_encode($view->args) : '[]'
But, this is wrong, $view_args should be set from the exposed filters.
I
- 🇪🇸Spain bmunslow
But, this is wrong, $view_args should be set from the exposed filters.
I think this is a big assumption to make, since not all views with contextual filters may have those filters exposed.
Good thing is draggableviews provides a hook to alter the view arguments if needed for a specific scenario, like the one you mentioned.
In my case, I use contextual filters for the Draggableviews Order page, but I display the results in a block that is rendered by means of the viewsreference_filter module, which exposes the filter instead of using contextual filters.
I was able to work around it by implementing the following
hook_draggableviews_join_withargs_alter()
as follows:/** * Implements hook_draggableviews_join_withargs_alter(). */ function MY_MODULE_draggableviews_join_withargs_alter(&$view_args, &$context) { if (empty($view_args)) { // Give draggable view a chance to use exposed filters as arguments, // since these may have been passed on from viewsreference_filter module. if (!empty($context['view_query']->view->exposed_raw_input)) { $view_args = array_values($context['view_query']->view->exposed_raw_input); } } }
In addition, I had to apply the RTBC patch in this issue: https://www.drupal.org/project/draggableviews/issues/3336466 🐛 "Pass Contextual Filters" option is broken on multiple sorts RTBC