Improve Views support

leafish_paul - March 31, 2009 - 19:35
Project:Role Weights
Version:6.x-1.x-dev
Component:External module integration
Category:feature request
Priority:normal
Assigned:Unassigned
Status:active
Description

Views stuff needs a complete re-write for Drupal 6/Views 2.

#1

Liliplanet - May 6, 2009 - 12:27
Title:Views 2 support» Views 2 support for Role Weights

I'm prepared to pay for the Role Weights update to 6.x to sort in views (via www.moneybookers.com) as follows:

The way it worked in 5.x was you were able to edit roles at admin/user/roles and set their weight.

Then in views you were able to sort the view by role weight in 'sort criteria'.

Basically I could have my highest roles show first in the view, then second, etc. It is for a member directory.

Would so much appreciate this capability and so important to my views.

Look forward to any suggestions, and again, thank you.
Lilian

#2

Liliplanet - May 24, 2009 - 14:42

* sorry for the bump * have to sort in views by role please :)

#3

leafish_paul - June 12, 2009 - 17:28
Version:HEAD» 6.x-1.x-dev

#4

leafish_paul - July 7, 2009 - 19:34
Title:Views 2 support for Role Weights» Improve Views support

Limited Views functionality equivalent to that in 5.x-1.5 added. Room for much improvement. #64071: Views support: when sorting by role weights a node appears three times. also needs addressing in both 5.x/6.x branches.

#5

leafish_paul - July 8, 2009 - 14:37

The biggest problem currently is that in joining the base node or users table to role_weights via users_roles, we create duplicates when users have more than one role (other than anonymous/authenticated).

After rummaging around Views docs and code, the same problem occurs in Views taxonomy support. Create a simple, new node view showing nodes with more than one term, sorted by Term ID. Duplicates appear for each node with more than one term.

So how to tackle this? I'm going to shout out on the Views dev group at some point soon, just noting some thoughts down now.

  • Sorting - need to identify which role (and role weight) to sort by. Eg, provide fields for "User: Lightest Role's Weight" and "Heaviest Role Weight".
  • Fields - what's useful? Lightest/heaviest Role ID, Lightest/Heaviest Role Name, Lightest/Heaviest Role Weight?
  • Can we improve the join at all?
  • Look at taxonomy terms again - anything there to help?
  • If not, can some other Views trickery help? Eg handlers, query alter etc.
  • The fix should be backported to 5.x if possible, as this problem is present there too (#64071: Views support: when sorting by role weights a node appears three times.)

Currently looking at maintaining a {role_weights_max} table, which would store:

|-------------------------|
|    role_weights_max     |
|-------------------------|
|  uid                    |
|  lightest_role_weight   |
|  heaviest_role_weight   |
|-------------------------|

and could be updated when a user's roles are modified, or role weights themselves are changed. With this table maintained, the Views join is much simpler and we can provide simple fields for Lightest/Heaviest Role Weight, for sorting at least.

#6

mcaden - August 21, 2009 - 06:38

EDIT: Nevermind, brain fart on my part looking at the query wrong.

 
 

Drupal is a registered trademark of Dries Buytaert.