Reviewed & tested by the community
Project:
DraggableViews
Version:
7.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
13 Feb 2013 at 13:42 UTC
Updated:
6 Jun 2019 at 15:11 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
istryker commentedI tested this module. This is the first taxonomy patch that handlers hierarchy.
I found one problem. The module does double indentation. This is gone once I removed the following:
Attach is the zip file, minus the above code, minus the 5 extra whitespaces, as a patch.
Comment #2
istryker commentedComment #3
istryker commentedSee #1916380: Roadmap to add taxonomy support to module
Comment #4
thesame- commentedYes. I didn't like the double indentation code neither. But the one in your module didn't fire cause it didn't pass this:
Probably because it doesn't use draggableviews_handler_sort.
I don't think it should check for sort handlers at this point as it has nothing to do with depth (hierarchy).
Comment #5
alexweber commentedConfirm that #1 doesn't work but #0, does.... tested against dev branch.
Comment #6
thesame- commentedAs I mentioned before in #4.
Comment #7
guedressel commentedI have no idea how this sub-module works. Or how my view needs to be set up to make this module work.
My view displays the terms of a hierarchical taxonomy "similar" to what it should look. Some terms are in mixed order or child of wrong parent...
Is this module still able to work on the current 2.x-dev head for draggableviews?
Or do I just don't get the point on how to build a draggable view using taxonomy weights and parents?
Comment #8
alexweber commented@guedressel I've had success with this patch, however, mostly due to the fact that it's a standalone sub-module, as opposed to actual changes in the original draggableviews module itself. Just drop in the sub-module and it'll work with a couple notices which are trivial to fix (not checking whether term has parents before accessing key).
Comment #9
guedressel commentedSorry. This module is not working for me.
Views result have the rows not sorted correctly.
Depth is correctly calculated, but without correct row order of the view result everything looks messed up.
Maybe you have an example view-export to show me how it would work?
Comment #10
jlyon commented@guedressel: I was able to make this work.
Dependencies
* draggableviews-7.x-2.0+56-dev (latest -dev)
Setting up view
* Enable Taxonomy Administration view (from https://drupal.org/project/admin_views)
* Add draggableview field
* Set Sort handler > Taxonomy Term
* Set Hierarchy handler > Taxonomy Term
Exported view is attached. Hope this helps.
Comment #11
georgir commented(disregard these attachments, instead see the ones in next post)
I added sorting of the rows in post-execute hook, attached is the result as a patch and as a zip.
It would not work with pager.
Also, I've not spent time figuring out the view variable structure, so I am not sure if there are cases where $view->field[X] is different from $view->display[$view->current_display]->handler->handlers['field'][X] or why this round-about way of accessing the field was deemed needed in the original preprocess implementation, but I've kept it.
There are still places in the code where use of $something->tid is hardcoded that should probably be replaced with $something->{$field->field_alias} for this to work when the draggableviews field is set to use some secondary relationship, etc. It works as is for the straightforward case though.
Since the changes from #1 are kept and the "(almost) duplicate" preprocess is removed in this version, you have to add the draggableviews sort handler in order to trigger the hierarchy preprocess from the base draggableviews module. If you use other sorts as well, you should probably add it last, and also add a sort by taxonomy term weight.
Comment #12
georgir commentedOops, in the above version I had messed up the sorting, here is the working one.
Comment #13
georgir commentedOne more small fix
Comment #14
b-prod commented@georgir: Thanks for your work.
This patch is a rewrite of the patch in #13. It adds required term properties directly to the view query, instead of making an extra query to retrieve the hierarchy. It removes the relationship with the draggable structure and modifies the sort handlers.
It fixes the way to sort the view result, which was not correct.
I tried to simplify the code and to stick to the Draggable Views module way. There are a lot of code comments to explain my choices.
Tested with some multilevel hierarchy successfully.
Notes:
Comment #15
b-prod commentedFor the problem of handling hierarchy with a pager, it seems to be a global issue with DV, isn't it? I found some issues about that.
Comment #16
istryker commentedHandling paging is a known problem with hierarchy. Hierarchy adds complexity as you can cut a hierarchy off.
Comment #17
b-prod commented@iStryker: OK, I confirm what I thought. So the pager issue is not specifically related to this taxonomy handler and my related remark in #14 can be ignored.
The patch below fixes a small bug when the order option is not defined in the field definition.
Comment #18
sinasalek commentedUse to get several warning and errors, by applying #17 all those errors and strange behaviors are gone and it works very well now :)
Marking it as RTBC
Tx @B-Prod
Comment #19
nwom commented#17 works amazingly. This is by far the best out of all of the taxonomy related solutions. Hierarchy works out of the box as well. Thank you!
Comment #20
nwom commentedI found a pretty big incompatibility for users that do not have permissions to edit the Taxonomy terms. For those users, none of the terms are shown and neither is the drag markers. By default, terms should still be shown, just not the edit links.
The following notices are shown on the page:
Comment #21
b-prod commentedActually modifying the weight and parents of a term need the "edit" permission, as those 2 are term properties that are only editable on the term edit form.
So users without the "edit" permission should not be able to reorder the tree.
How did you get these notices?
Comment #22
nwom commentedIn this case the notices appear automatically when viewing the views page without draggable access permissions.
Comment #23
nwom commentedI managed to fix the notice. Attached is both the patch and the interdiff. Please review.
Comment #24
nwom commentedComment #25
nwom commented#23 still applies cleanly against the newest dev.
Comment #26
FireHawkX commented#23 Indeed still works fine with latest dev version :)