Create views integration and provide a relationship

merlinofchaos - July 18, 2008 - 17:01
Project:Content Profile
Version:6.x-1.0-beta2
Component:Base module
Category:feature request
Priority:normal
Assigned:Unassigned
Status:closed
Description

Creating a content_profile.views.inc that provides a relationship between the users table and the node table. That would make it very easy to create a 'users' view, add the relationship to the node, and get all the information available. The code for this should not be too difficult as it should be a reasonably straightforward relationship. Just use hook_views_data_alter to add the relationship to the 'users' table and there might be a benefit from adding a relationship to the 'node' table as well.

See nodequeue module for an example of a relationship that works like this; that's the best documentation I can think of.

#1

fago - July 22, 2008 - 12:42
Component:Code» Base module
Status:active» fixed

thanks a lot for the pointer - I've just done so.

--> http://cvs.drupal.org/viewvc.py/drupal/contributions/modules/content_pro...

Seems to work fine. Really awesome how great views 2 handles relationships!

I started with the code from nodequeue as suggested and noted that

<?php
    
'real field' => 'nid',
?>
from the relationship isn't respected. Looking at the relationship query code, it seems to doesn't respect 'field' either, but base and base field.

I had to create my own handler for adding the right extra nevertheless, just wanted to let you know.

#2

merlinofchaos - July 23, 2008 - 15:48

'base' and 'base field' would be the fields on the right. 'real field' should be the field on the left. Hmm. I'll have to look into that. Thanks.

#3

Anonymous (not verified) - August 6, 2008 - 15:52
Status:fixed» closed

Automatically closed -- issue fixed for two weeks with no activity.

#4

patrickgmj - August 18, 2008 - 17:58
Version:6.x-1.x-dev» 6.x-1.0-beta2
Status:closed» active

Using the contributed code linked to above, I'm trying to make a view that will get a list of the users in a group, using the data from content profile fields. I'm getting the following SQL errors:

I'm not nearly good enough to figure this out. Could it be a change in the content-profile module (contrib code was for dev version), or is it something to do with making it play nice with og? (OG version is rc4)

Thanks much,
Patrick

* user warning: Unknown column 'node.type' in 'field list' query: SELECT COUNT(*) FROM (SELECT users.uid AS uid, users.picture AS users_picture, users.name AS users_name, node.type AS node_type, node_users__node_data_field_firstname.field_firstname_value AS node_users__node_data_field_firstname_field_firstname_value, node_users__node_data_field_firstname.nid AS node_users__node_data_field_firstname_nid, node_data_field_firstname.field_lastname_value AS node_data_field_firstname_field_lastname_value, node_data_field_firstname.nid AS node_data_field_firstname_nid, og_uid.created AS og_uid_created FROM users users INNER JOIN node node_users ON users.uid = node_users.uid AND node_users.type = 'profile' LEFT JOIN og_uid og_uid ON users.uid = og_uid.uid LEFT JOIN content_type_profile node_users__node_data_field_firstname ON node_users.vid = node_users__node_data_field_firstname.vid WHERE (users.status <> 0) AND (og_uid.nid = 28) ORDER BY og_uid_created DESC ) AS count_alias in /home/umwdtlto/public_html/teachumw/modules/views/includes/view.inc on line 652.
* user warning: Unknown column 'node.type' in 'field list' query: SELECT users.uid AS uid, users.picture AS users_picture, users.name AS users_name, node.type AS node_type, node_users__node_data_field_firstname.field_firstname_value AS node_users__node_data_field_firstname_field_firstname_value, node_users__node_data_field_firstname.nid AS node_users__node_data_field_firstname_nid, node_data_field_firstname.field_lastname_value AS node_data_field_firstname_field_lastname_value, node_data_field_firstname.nid AS node_data_field_firstname_nid, og_uid.created AS og_uid_created FROM users users INNER JOIN node node_users ON users.uid = node_users.uid AND node_users.type = 'profile' LEFT JOIN og_uid og_uid ON users.uid = og_uid.uid LEFT JOIN content_type_profile node_users__node_data_field_firstname ON node_users.vid = node_users__node_data_field_firstname.vid WHERE (users.status <> 0) AND (og_uid.nid = 28) ORDER BY og_uid_created DESC LIMIT 0, 5 in /home/umwdtlto/public_html/teachumw/modules/views/includes/view.inc on line 677.

#5

fago - August 19, 2008 - 08:09
Status:active» closed

Might be an og issue - I don't think it's a content profile issue. Open separate issues please.

 
 

Drupal is a registered trademark of Dries Buytaert.