Hi,

I am using draggableviews to sort content related to a category. Because there is so much content, and the content is viewed only per category, I created the sorting with a block that appears on the category page. The category nid is set as a contextual filter. I selected 'Do not use any arguments'.
In the actual view where the sorting is applied I added the same sorting.
I expected the values to be saved in the database without args, but they appear there anyway and the sorting doesn't work. I tried return array() as php code, but that didn't do anything either. I can get the sort to work if I select 'All arguments', but only in the sorting block, not in the view that needs to apply the sorting.

I'm not sure this is a bug, because it makes sense to apply the argument. However, the category cannot be passed as a contextual filter on the target view. I need to tell draggableviews which argument to use, if only I knew how to pass it on. How could I pass the value for a specific views field (e.g. nid) as an argument? An example would really help.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

iStryker’s picture

So you have content with a taxonomy called category. You want to order each category page, so you have 1 view with 2 display, one as the draggableview order, the other one that has the weight applied but no draggable component.

Background info:

Roughly how it gets save to the database
nid arg weight view_name view_display
3 [tid:1] 0 same same
1 [tid:1] 1 same same
2 [tid:1] 2 same same

if you don't save the arguments
3 [] 0 same same
1 [] 1 same same
2 [] 2 same same

Something tells me you need all arguments for both. Are you using exposed filters?

iStryker’s picture

After more testing

Contextual Filter "fruit/apples"
Save to database ["fruit", "apples"]
nid arg weight view_name view_display
3 ["fruit", "apples"] 0 same same
1 ["fruit", "apples"] 1 same same
2 ["fruit", "apples"] 2 same same
5 ["fruit", "oranges"] 0 same same
4 ["fruit", "oranges"] 1 same same
6 ["fruit", "oranges"] 2 same same

if you go to non-drag view page, test/fruit/apples and test/fruit/oranges it works with all arguments.
if you go to non-drag view page, test/fruit/apples and test/fruit/oranges it does not work with do not use arguments, as it searches the database for arg [].

if your drag view page uses 'do not use arguments' then.
When you save the order of the "fruit/apples" view, the database adds 3 entries.
3 ["fruit", "apples"] 0 same same
1 ["fruit", "apples"] 1 same same
2 ["fruit", "apples"] 2 same same
When you go back to your draggableview, the weights/order does not work as it queries the database for [] arguments.

If you have expose filters, then the problem gets work.

pezia’s picture

Category: Support request » Bug report
FileSize
1.79 KB

I think this is a bug.

I've set the sort by draggable views weights, chose "Do not use any arguments (use empty arguments)". The ordering list was OK (used no arguments JSON for the select), but the saving does not consider this option.

pezia’s picture

Component: Documentation » Code
robertragas’s picture

I must say I had the same issue with a contextual filter for taxonomy category but when I edited the 3 views ( sort-view and the 2 other views connected to this) and chosen to not use arguments for the draggable weight filter on all the 3 views it worked.

iStryker’s picture

@Pezia, I think I can make out what your patch does, but can you explain more what you patch does not do (problems you are still having).

pezia’s picture

@iStryker: this patch solved my problem entirely.
Saves no-arg json as expected when "Do not use arguments" is set.

I could not get the tests to work yet, so I can't create a test case for this.

umberto.’s picture

patch #3 work very well for us.

gapple’s picture

Status: Active » Reviewed & tested by the community

I was debugging the PHP filter option not functioning as expected, and it was a shocking moment to find out that the configured argument options were applied when sorting in draggableviews_join_handler, but not when saving in draggableviews_handler_native. This patch makes the configuration work as expected when saving an ordering configured to not use arguments, or use PHP to modify the arguments.

abrlam’s picture

Status: Reviewed & tested by the community » Needs review
FileSize
1.03 KB

Can we go one step further by completely ignoring the arguments scan (draggableviews_structure.args) when the view arguments are empty? See patch attached.

dtamajon’s picture

I have the same problem, and the #10 solution is working but is changing the meaning of the empty arguments option. I think would be better to add a new "Empty arguments (no arguments in the query)" option.