I would like the ability for each user to sort the view separately as he or she sees fit, and have the information persist with the user ongoing.
The use case is this:
I run a bicycle-powered composting business. People who work with me, have to chose their route each week, and may originate from different places (their respective homes). So each rider would prefer to be able to order the list of addresses (the view) to his/her own liking so (s)he may print that each week, and have that stick going forward.
I am happy to work on the implementation, but would like a little guidance in terms of how you might envision the execution of this.
Comments
Comment #1
istryker commentedI believe you need to create a contextual filter of the User:UID, with it defaulting to the current user id if none is provided.
Currently there is no contextual filters for Draggableviews, so you have to find examples of how to write it else where.
Comment #2
istryker commentedOk here is the start. I will leave this for someone else to finish.
I added this to Draggableviews'
views/draggableviews.views.incfile:This change the query:
draggableviews_structure.args = '[]'todraggableviews_structure.args '[\"X"]'and added
WHERE (( (draggableviews_structure.args = 'X' ) ))I also referenced Views'
modules/user.views.incfileComment #3
chrisarusso commentediStryker,
I plan to implement this soon (within a week). Any advice on how to implement if I'd like to allow a user to use another user's sort on a view? UID 1 may, at times, want his own sorted order of a view, but at other times, may want to use UID 2's sorting. He also may want to copy (overwrite) UID 2's sorting to his own. Knowing the module better, I'll defer to where you think that logic should go.
Thanks for the headstart on this.
Comment #4
istryker commentedTo solve everything you want, I feel like this would be a custom sub-module, where it would add a uid column to the draggableviews_structure table in the database. This would only work with Native handler (not EntityAPI or FieldAPI). Then you can do multiple things, with custom GUIs and custom permissions (allow copying, allow to view others users sort view, etc).
I am leaning towards adding a UID column to the database, but haven't discovery enough use cases for this that one weighs the additional complexity it adds. In addition, it would only work with Native handler.
For the near future, the goal of this module is to provide different sort per user by using exposed or contextual filters.
Comment #5
p_tamas commentedHello.
I had a similar need and I resolved the problem like this:
Added a new configuration type to Sort criteria.
User or Global
If you select user it will automaticly save your user id in table when you save your customization.
Global will bee same as the regular draggableview.
I have created a patch and i will create soon a tutorial with it.
Comment #6
arirasekh commented@p_tamas - I was excited to see that you've implemented a solution to this problem but I can't seem to install the patch. Here's what I did and the resulting error (I'm fairly inexperienced when it comes to installing patches so please let me know if I've done something wrong). Any advice?
I'd welcome that tutorial you mentioned if you've made any progress on it.
Thanks!
Comment #7
eojthebraveI was able to get this working in the current dev version of the module without having to apply any patches. I added a Context/Argument of Global: Null and then set the default value to the ID of the current logged in user. After that I could tell the Draggable Views: Content field to use all arguments and it ends up saving per-user sort order data.
Seems to be working pretty well so far FWIW.
Comment #8
manuelBS commentedyeah thanks for this nice hint @eojthebrave it works like this perfect!
Comment #9
istryker commentedComment #10
bwoods commentedI'm pretty certain that #7 doesn't work, at least, with the current 7.x-2.2 code. I've looked at this multiple times and see no code that would indicate user info is being saved. Is it possible that the code to do this was removed in favor of something else for 2.2?
Comment #11
istryker commentedCode looks old, but too old. Should be able to re-roll. At first glance the old thing that looks gone is $query_get_old...pretty sure that is stripped out. 7204 needs to be rolled with latest update hook #.
Comment #12
bwoods commentedThe patch mentioned in #5 does seem to work with 7.x-2.2 code, despite a couple of patch fails. From what I can tell, the parts of the patch that fail are in the install and now a part of the db schema. My guess is that eojthebrave applied most of the patch and then used #7 to distinguish between users by utilizing the logged-in user id. Can anyone else confirm this? I think it's a little disingenuous to mark something as already fixed when it really isn't. But please correct me if there's something I'm missing here.