Posted by leafish_paul on May 3, 2006 at 6:31pm
Jump to:
| Project: | Role Weights |
| Version: | master |
| Component: | External module integration |
| Category: | task |
| Priority: | normal |
| Assigned: | leafish_paul |
| Status: | closed (fixed) |
Issue Summary
One obvious use for this module would be with Views. A view could then sort its nodes by role weights.
Comments
#1
OK, struggling with this one. Posting to try and get some help ;)
Role Weights now has a simple database table containing a {rid, weight} pair. Therefore, I should able to JOIN node to user_roles via uid, then user_roles to my role_weights table via rid.
Based on the Views developer docs and hunting through various contrib modules, here's what I have so far:
<?php
function role_weights_views_tables() {
$tables['users_roles'] = array(
"name" => "users_roles",
"join" => array(
"left" => array(
"table" => "node",
"field" => "uid",
),
"right" => array(
"field" => "uid",
),
),
);
$tables['role_weights'] = array(
"name" => "role_weights",
"join" => array(
"left" => array(
"table" => "users_roles",
"field" => "rid",
),
"right" => array(
"field" => "rid",
),
),
"sorts" => array(
"weight" => array(
'name' => "Role Weights: role weight",
'field' => array('weight'),
'help' => t("Order nodes by author's role weight"),
),
),
);
return $tables;
}
?>
Which, I thought could work, but alas no. Can anyone spot what I'm doing wrong? Thanks!
#2
Thanks to moshe and eaton on IRC for pointers! With Views and Role Weights enabled, views can now access/display or sort by the node author's role weight.
This is still relatively untested.
#3
Slowly but surely, views.module marches towards world domination. ;-) Looks like a great piece of work, paul. I'll have to try it on one of my editor/user oriented sites.
#4
Please do, it needs proper testing!
(I also use it on a dev site to display different icons for roles next to usernames - users can be in multiple roles, but the icon will always show the 'highest' role icon)
#5