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.
Comments
Comment #1
iStryker CreditAttribution: iStryker commentedSo 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?
Comment #2
iStryker CreditAttribution: iStryker commentedAfter 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.
Comment #3
pezia CreditAttribution: pezia commentedI 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.
Comment #4
pezia CreditAttribution: pezia commentedComment #5
robertragas CreditAttribution: robertragas commentedI 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.
Comment #6
iStryker CreditAttribution: iStryker commented@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).
Comment #7
pezia CreditAttribution: pezia commented@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.
Comment #8
umberto. CreditAttribution: umberto. commentedpatch #3 work very well for us.
Comment #9
gappleI 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.
Comment #10
abrlam CreditAttribution: abrlam commentedCan we go one step further by completely ignoring the arguments scan (draggableviews_structure.args) when the view arguments are empty? See patch attached.
Comment #11
dtamajon CreditAttribution: dtamajon commentedI 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.