I had an interesting request from a client today and I'm not exactly sure the best way to solve it using Drupal Views. They currently have a "Team Member" content type that represents members of their staff. Each staff member page has a link to all other staff member pages. So far that's not a problem.
They want this list to start with the person we're presently looking at and then proceed with who falls right after them in the "sorted" order. Then when it reaches the end of the list it wraps around and starts back at the beginning until they get back to themselves (similar to how a Circular Linked List would work).
So for example, assume I have Team Members A,B,C,D,E,F and G:
- If I'm looking at Team Member A, the list order is: A, B, C, D, E, F, G.
- If I'm looking at Team Member D, the list order is: D, E, F, G, A, B, C.
- If I'm looking at Team Member G, the list order is: G, A, B, C, D, E, F.
If I was dealing with some other data structure in a regular programming environment, I'm sure I could come up with some sort of algorithm to determine where we presently at and begin sorting from there and fake a "circular list". Views seems a little more tricky.
The only potential solution I can think of would be to create two separate views and then just join the results together after the fact.
- One view would be a sorted list of all team members that have a sort number greater than or equal to the present team member.
- A second view that is a sorted list of all team members that have a sort number less than or equal to the present team member.
I'm just curious if there are any more efficient ways of doing this kind of a sort with views?