By telex4 on
I'm working on exposing the data in the signup module to the views module. So far I've got a table view that lists nodes and one user signed up to each node, but it doesn't handle multiple values, i.e. where a node has two or more users signed up.
How do I handle that?
Here's the code I'm using:
/**
* Hook to expose signup data to views module
* @ingroup signup_views_api
*/
function signup_views_tables() {
$tables['signup_log'] = array(
'name' => 'signup_log',
"join" => array(
"left" => array(
"table" => "node",
"field" => "nid"
),
"right" => array(
"field" => "nid"
),
),
"fields" => array(
"uid" => array(
'name' => "Signup: Users",
'handler' => 'views_handler_field_signupname',
'sortable' => false,
),
),
);
return $tables;
}
/**
* Handler to return pretty usernames instead of fairly useless uid info
* @ingroup signup_views_api
*/
function views_handler_field_signupname($fieldinfo, $fielddata, $value, $data) {
$obj = user_load(array('uid' => $value));
return theme('username', $obj);
}
Comments
And on a related note, is
And on a related note, is there a proper way to handle multiple taxonomies, each with multiple possible entries? I read this thread but that looks like I'd need to tie specific taxonomies into the module code, which I obviously don't want to do with signup.
So that's different fields for different taxonomies, and fields with multiple values per row. Suggestions are most welcome.
The 1::many relationship is
The 1::many relationship is always an interesting trick for views.
You can't easily pull multiple values in on a single query.
You can, however, do a second query in your fieldhandler.
If your signup is, itself, a node type, you can set up a view on that node type, and use an argument to represent the parent, so that you then query all nodes that are attached to the node in question.
(Sorry I didn't find this sooner. Filing support requests under the views project will get my attention a lot faster).
-- Merlin
[Point the finger: Assign Blame!]
[Read my writing: ehalseymiles.com]
[Read my Coding blog: Angry Donuts]
-- Merlin
[Read my writing: ehalseymiles.com]
[Read my Coding blog: Angry Donuts]