Titles assigned in one group carry over to all other groups. A user who is a 'Member' in one group but 'Committee Chair' in another (for instance) will be listed as whichever was created first.

To make things worse, if their title is set in the second group - they will have 2 entries in that group. Clearly, multiple values are able to be stored for each user, but views is unable to filter this and lists the user for each title.

CommentFileSizeAuthor
#8 og_titles-views.patch1.3 KBmradcliffe

Comments

mradcliffe’s picture

Assigned: Unassigned » mradcliffe

Hmm, it seems that the

"Organic groups: Group node (member)" relationship breaks things. I'm going to have to re-investigate the best way to do views support.

Thank you.

mradcliffe’s picture

Status: Active » Needs work

It looks like the best way to do this is not to use the og_uid table at all, but to duplicate functionality of it instead. :|

Still working on things.

justin.hopkins’s picture

Thanks for looking at it. Sounds like it's in good hands!

dtarc’s picture

How's this coming? I'm happy to help test and possibly muck around with the code. I want to get this working and there's a very similar issue in OG User Roles involving similar functionality, with the group context not being taken into account with the filter handler.

#406762: Using Views to show users with a particular OGUR role in a group

justin.hopkins’s picture

I'd be happy to contribute my time and effort on this one too - but I'm really more of a novice and have been confounded looking at the module trying to understand why this isn't working.

One of my personal and professional goals is to better understand how to contribute modules, so if you can suggest any reading that might help me grok this - I'd certainly love to dive in!

mradcliffe’s picture

Priority: Normal » Critical

I keep running into an issue trying to join directly with the og_uid table. Whenever I do that none of my views fields or filters show up! If I duplicate functionality of og's og_uid views, then I have to include a bunch of duplicate views data, which may make things more confusing.

Basically, I wish I could do this:

        $data['og_uid_titles']['table']['join'] = array(
                'og_uid' => array(
                        'left_field' => 'uid',
                        'field' => 'uid',
                        'extra' => '{og_uid}.nid = {og_uid_titles}.nid',
                ),
        );

Instead of

        $data['og_uid_titles']['table']['join'] = array(
// this is what $data['og_uid']['table']['join'] = array( does too
                'users' => array(
                        'left_field' => 'uid',
                        'field' => 'uid',
                'node' => array(
                        'left_field' => 'nid',
                        'field' => 'nid',
                ),
        );

        $data['og_uid_titles']['nid'] = array(
               'title' => t('Group Titles: Group id'),
               'help' => t('The group id of the group'),
               'relationship' => array(
                       'handler' => 'views_handler_relationship',
                       'base' => 'node',
                       'relationship field' => 'nid',
                       'label' => t('Group node (member)'),
               ),  
               'argument' => array(
                       'title' => t('Group node'),
                       'handler' => 'og_views_handler_argument_og_uid_nid',
                       'help' => t('This is the same argument as og_uid table.'),
               ),  
       ); 

       // and so on duplicating everything og_uid does so you have the same functionality...

This og issue is interesting though #388936: OG Views: user's groups field.

justin.hopkins’s picture

Yeah so I saw #408372: Joining tables to og_uid in custom module and it looks like moshe doesn't have anything to offer. That's too bad.

Do you have the functionality working with the 'non-ideal' solution?

mradcliffe’s picture

StatusFileSize
new1.3 KB

I have a patch that changes how og_titles views works. You shouldn't try adding fields or filters via og_uids default views though. Maybe try using og development/head which has a patch that adds an alternate way of filtering og members. I really do wish that I could integrate this so that you could just override og faces or og list views.

Also, the default view won't work, you need to create your own.

justin.hopkins’s picture

Thanks for the patch, but I have to be honest and say I really don't understand what you mean when you say: "You shouldn't try adding fields or filters via og_uids default views though." What is another way to create a per group view on each groups page?

mradcliffe’s picture

Status: Needs work » Needs review

I have a better workaround now, but it probably still needs additional work/testing.

I implement the join with og_uid as a relationship. If you use the "Group Title: Membership" relationship you should be able to pull in the og_uid fields, sorts, and filters without any duplication. To get the nodes you need to use "Group Title: Group Id" or whatever it is called.

Just recently committed to CVS (http://cvs.drupal.org/viewvc.py/drupal/contributions/modules/og_titles/o...).

Probably best to wipe out the directory and import from cvs if you don't want to wait for the snapshot release to update tonight.

justin.hopkins’s picture

Awesome thanks so much Matthew!

After looking at the new view you included in the cvs version I was able to replicate it with my existing views just by adding the two new relationships.

You rock dude! I wish I had had a chance to meet you in person at Drupalcon D.C.

mradcliffe’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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

bls20’s picture

Just wanted to Also Say thanks for working this out!! Helped to resolve my Dupe problem by changing the relationship.
so um yeah.... THANK-YOU!

DanilaD’s picture

Hello.

Could you please post an example of a working view (exported) that shows different titles in different groups if a user does have different titles? I've checked different various of relationships, and finally I was able to get where I need by using CustomField module with this PHP field:

     $result = db_query_range('SELECT n.title
FROM {og_uid_titles} n WHERE (n.uid = %d) AND (n.nid = %d)', array($data->og_uid_uid, $data->og_uid_nid), 0, 1);
     while ($title = db_fetch_object($result)) {
        print check_plain($title->title);
  }

But I know it's not efficient, as an SQL query is generated once per each member in a group :(

I use 6.x-1.x-dev, downloaded on July 28th, 2010.

Regards,
Danila