Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
According to the documentation DraggableViews should include the view's arguments in the saved data, so per argument the ordering can be saved. In the Drupal 8 version of DraggableViews this is not the case. Args is always filled with '[]' and ignored when joining the view.
I'll attach a patch to fix this.
Comment | File | Size | Author |
---|---|---|---|
#18 | 2903567-17.patch | 3.14 KB | iStryker |
#12 | draggableviews-args-not-working-2903567-12-D8.patch | 3.88 KB | zanvidmar |
#10 | draggableviews-args-not-working-2903567-10-D8.patch | 3.21 KB | johnnybgoode |
#7 | 2903567-07-args.patch | 3.02 KB | nicrodgers |
#6 | interdiff.txt | 856 bytes | nicrodgers |
Comments
Comment #2
Rolf van de Krol CreditAttribution: Rolf van de Krol commentedPatch
Comment #3
iStryker CreditAttribution: iStryker commentedNeed test to test this. Probably another view added to Draggableviews Demo module, then another test added to test it.
Comment #4
iStryker CreditAttribution: iStryker commentedAdding this to 8.x-1.1 release
Comment #5
friera CreditAttribution: friera as a volunteer commentedI provide and updated patch to solve that.
Comment #6
nicrodgersPatch works great, thanks! I've added in a call to \Drupal::moduleHandler()->alter() to give other modules a chance to edit or ignore some of the view args. In our case, this was a really useful addition.
Still needs tests though so leaving as needs work.
Comment #7
nicrodgersRe-uploading the patch from #6, due to some weird caching issues on d.o.
Comment #8
sheise CreditAttribution: sheise at Zivtech commentedThanks! I'm using the patch from #7 and everything seems to be working as it should.
Comment #9
stephenebersole CreditAttribution: stephenebersole at Rosewood Marketing commentedYes, Thank you for patch #7. We have a site in development where we have a view of products contextually filtered by taxonomy. Prior to this patch when we set the order on one contextually filtered page, it would affect other contextually filtered pages. This patch resolved the issue for us!
Comment #10
johnnybgoode CreditAttribution: johnnybgoode at Third and Grove commentedThanks for the work here everyone! The patch in #7 works great with views using contextual filters. I had a use case where I needed to create a draggable view with an exposed filter to allow users to sort posts by category, so I've updated the patch to include exposed filters in the `args` data as well.
Comment #11
rhovland CreditAttribution: rhovland commented#10 works well
One thing I realized while testing is that this is potentially breaking functionality on existing sites. Pages that have arguments would lose their sorting because context has changed, and they don't exist.
To not break existing sites and make this more useful we need control over what arguments are used. By default arguments would not be enabled. When adding a sort to a view using draggableviews data you would check boxes next to which arguments you want to use.
Comment #12
zanvidmar CreditAttribution: zanvidmar as a volunteer commentedIf you have two instances of same view (id and display) on same page, with different arguments, draggable function does not work because html id is identical. This patch is fixing that issue.
I updated it as addition to patch #10 and as standalone patch.
Update: this patch only works with https://www.drupal.org/project/draggableviews/issues/2867348. In the next comment it is fixed patch
Comment #13
zanvidmar CreditAttribution: zanvidmar as a volunteer commentedFix for #12 patch.
Comment #14
mErilainen CreditAttribution: mErilainen at Wunder commentedI started to get duplicates after applying the patch and saved the listing in two languages, see the attached screenshot. For some reason there is an empty array "[]" saved along with the "langcode" parameter. If I come to the view and the default value "English" is selected, I don't have any value in the url, and this is saved as two empty arrays "[][]" to the database. This is not visible in the screenshot though.
Comment #15
nicrodgersI wonder if it's better to limit the scope of this issue to just contextual filters, as per the patch in #7 and deal with exposed filters in a separate follow-up? Here's a re-roll of #7 for the latest 1.x-dev.
Comment #16
iStryker CreditAttribution: iStryker commentedmErilainen is correct, Patch #10 wil add two [][] because of
Re-rolling #15 and committing (after testing).
Exposed filters can be moved to a separate issue.
Comment #18
iStryker CreditAttribution: iStryker commentedAttached is re-rolled patch (with code cleanup of WithArgs.php)
Comment #19
iStryker CreditAttribution: iStryker commentedAdding related issue to fix expose filters
Comment #20
deepaksingh05 CreditAttribution: deepaksingh05 as a volunteer commentedPatch #18 not working for me.
Patch "draggableviews-args-not-working-2903567-13-D8.patch" is working for me only for reordering on the sorting page.
But the rendering Views is not able to get the draggable weight, getting weight = 0, and content not reflecting in an ordered manner.
It was working perfectly before my Drupal core didn't update to 8.8.
Comment #21
Ralf Eisler CreditAttribution: Ralf Eisler commentedThe problem still exists with the actual dev version of the module.
I am working with:
-- Drupal 8.8.0 and
-- DraggableViews 8.x-1.2+8-dev (2019-Dec-06)
For the installation and configuration I followed the instructions in the README.md file.
I configured several views with node listings and the according views to change the order in which the nodes are displayed.
First problem: The DraggableViews Weight sort criteria does not display a weight value in the view to reorder the nodes. “Show row weights” shows empty fields.
Error message:
Notice: Undefined property: Drupal\views\ResultRow::$draggableviews_structure_weight in Drupal\draggableviews\Plugin\views\field\DraggableViewsField->viewsForm() (line 124 of /my-website.localhost/docroot/modules/contrib/draggableviews/src/Plugin/views/field/DraggableViewsField.php) #
Second problem: I configured several views to display nodes:
There is the following text in the README.md file there should be an option to choose the title of a view for reordering a specific list:
*Things to confirm after you saved your new view.
- In the Administrative Views UI, Go back to your View's 'page' display.
-> Click 'Draggableviews: Weight (asc)' under 'SORT CRITERIA'
-> You should see:
Display sort as:
()
This option does not show up.
Comment #22
iStryker CreditAttribution: iStryker commented@Thomas unless your issue relates to this issue, do not post in a comment here. Please open a new issue.
Comment #24
alisonSeeing #20 from @deepaksingh05 -- has anyone else had a change in effectiveness of this fix since updating Drupal core to 8.8.x (from 8.7.x)?
The draggable weights aren't working for me on view page displays with a contextual filter/argument in the URL (i.e. /people/25 where 25 is a term ID) -- I tried adding the draggableviews weight value as a field to the view, and even in the view preview, it just says "0" for each view result (when I clear the argument in the view preview, the draggableviews weight values show and sort properly).
...But I don't know if this problem was happening before 8.8.x, I didn't have this particular view situation back then :-/ Anyway, figured I'd ask!
(EDIT: I do have the latest dev version.)
Comment #25
ghaya CreditAttribution: ghaya commentedI seem to have a similar problem to #24. After a recent update to 8.92 my draggable views with arguments stopped sorting. I am not sure exactly when the sorting stopped working so it may have even been with a previous update.
Revision: I hade the latest dev version installed, the sorting started working again when I went back to the stable version and applied this patch https://www.drupal.org/files/issues/2903567-07-args.patch