I guess this is technically a feature request, but it seems like there should be a dropdown or other choice selector for filtering group content views by group audience. I couldn't find one.

Is OG missing this exposed filter widget, or did I just overlook how to implement it?

Files: 
CommentFileSizeAuthor
#41 og-filter-group-audience-select-1109676-41.patch2.44 KBzengenuity
PASSED: [[SimpleTest]]: [MySQL] 745 pass(es).
[ View ]
#39 og-filter-group-audience-select-1109676-39.patch3.07 KBzengenuity
PASSED: [[SimpleTest]]: [MySQL] 745 pass(es).
[ View ]
#24 og-1109676-24_add-filter-widget.patch1.96 KBavr
PASSED: [[SimpleTest]]: [MySQL] 715 pass(es).
[ View ]
#16 1109676-16-og-group_audience_widget.patch2.41 KBpfrenssen
PASSED: [[SimpleTest]]: [MySQL] 1,000 pass(es).
[ View ]
#13 widget_to_filter_groups-1109676-13.patch1.75 KBavr
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch widget_to_filter_groups-1109676-13.patch. Unable to apply patch. See the log in the details link for more information.
[ View ]
#11 widget_to_filter_groups-1109676-11.patch1.92 KBavr
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch widget_to_filter_groups-1109676-11.patch. Unable to apply patch. See the log in the details link for more information.
[ View ]

Comments

I just wrote a handler to modify this behavior, if anyone wants it let me know. Maybe this should go into core. One thing I noticed was that og views api stuff is out of date and not functioning. OG stuff is available in views only through the field views API framework.

My handler works because I use views_data_alter on the og fields views data to swap in my custom handler.

> One thing I noticed was that og views api stuff is out of date

Can you provide a patch?

> One thing I noticed was that og views api stuff is out of date

Can you provide a patch?

subscribe

Status:Active» Fixed
Issue tags:-filter, -dropdown, -Group Audience

Views integration was overhauled.

Status:Fixed» Closed (fixed)

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

Status:Closed (fixed)» Active

Hi Amitaibu,
What do you mean by Views integration was overhauled? I'm still not able to create an exposed filter dropdown by group audience for group content.

Maybe I miss something. I'm also not able to create an exposed filter dropdown by group audience for group content.

Title:There is no dropdown widget for filtering group content by group audienceAdd widget for filtering group content by group audience in Views
Category:support» feature

> I'm also not able to create an exposed filter dropdown by group audience for group content.

There isn't a group list, you can filter by, only by the group ID. I'm willing to review a patch that will add such a list / autocomplete.

StatusFileSize
new1.92 KB
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch widget_to_filter_groups-1109676-11.patch. Unable to apply patch. See the log in the details link for more information.
[ View ]

The attached patch allows for a selecting groups when using the "Field: Groups audience:gid" field.

I can't see any difference after the patch. There is still no dropdown as an exposed filter for groups.

StatusFileSize
new1.75 KB
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch widget_to_filter_groups-1109676-13.patch. Unable to apply patch. See the log in the details link for more information.
[ View ]

I've noticed in Views that I have to refresh/clear cache a few times to get the form to display as expected.

Here's a reroll of the patch. According to some inline documentation, it looks like the preferred method is to use the "Og membership" entity instead of the group_audience_gid field. So, to use this new patch:

1. Add a "Views Relationship" for "Group membership: Node group membership"
2. Add a filter field for "Og membership: group id" and use the new "Group" relationship

@avr
Now it works. Great. Thanks for your work.

Thanks avr for the patch.

It looks like this patch will not work with latest dev.
I am getting this error. "The operator is invalid on filter: OG membership: OG group gid".

Status:Active» Needs review
StatusFileSize
new2.41 KB
PASSED: [[SimpleTest]]: [MySQL] 1,000 pass(es).
[ View ]

Awesome, works great. The patch did not apply any more so I have updated it to the latest 7.x-1.x branch.

The terminology has also changed a bit in the latest versions, so here are some updated instructions on how to use this patch:

  1. Apply the patch.
  2. Clear the cache.
  3. Add the relationship "OG membership: OG membership from Node" to your view.
  4. Add the filter "OG membership: OG group gid" using the above relationship.
  5. Make sure the filter is exposed and that AJAX is enabled.

Status:Needs review» Reviewed & tested by the community

I applied the patch in #16, and can confirm that it works. By now, there are a few features in the 7.x.1.x-dev branch that are not in 7.x-1.3. Maybe it is time for a 1.4 release?

Still working in 7.x-1.4.

When I followed the steps above, I got this in the filter criteria:

(OG membership from node) Broken/missing handler (= )

And events that are posted to multiple groups show on the calendar 6 times (once for each group)

#16 patch worked great for me on OG version = "7.x-1.4". Thank you so much!

It would be great to see this feature rolled into the module.

Version:7.x-1.x-dev» 7.x-2.x-dev
Status:Reviewed & tested by the community» Needs work

Let's move it to 2.x. The filter should be adjusted to the fact we no longer have a single group, but different entities.

I too am looking for this feature.

Does this mean the patch must be updated to work with 2.x ?

Thanks,

StatusFileSize
new1.96 KB
PASSED: [[SimpleTest]]: [MySQL] 715 pass(es).
[ View ]

Here's a new version of the patch that applies to 7.x-2.x.

There is a TODO for adding an initial settings form in the handler to select both the state and the type of entity to be filtered.

The original instructions still apply:

  1. Create a new view
  2. Add a relationship of: "OG membership: OG membership from Node"
  3. Add a filter of: "OG membership: Group ID"

You should now have a select list instead of a plain text box. Exposing the filter works as expected.

Status:Needs work» Needs review

Updating to "needs review"

The patch is against 1.x, no?

This patch should be against 2.x. Just checked again - it applies. Perhaps I'm missing something?

Status:Needs review» Needs work

I think we should task another approach, in the line of EntityReferenceBehavior_ViewsFilterSelect::views_data_alter()

  • We should rely on user activating "Enable Render Views filters as select list" in the field settings
  • Add the group-audience field to the View -- up until here everything works ok, and you see the list of groups you may access.
  • Our code should alter the field handler to query the OG membership instead of looking directly at the empty field's table.

@avr, is it something you can investigate?

Thanks for the feedback. I didn't even realize all of the changes that have been made to the field widget. That being said, I'm not familiar with how this should work - but I'll take some time to learn.

getting same as #20. Broken/missing handler.

The patch from #16 applies cleanly for me against 7.x-1.4 but it still appears as a text field and not as a dropdown. I have cleared my cache and am using a "OG membership from User" instead of from node on my view of users that I would like to filter by their respective groups. Ajax is enabled.

Any idea if this would need changing to work with a user relationship?

Sorry it was my fault - one of the patched files didnt upload. It works correctly thank you !

I do however receive this error using latest dev of Entity on this view

Notice: Trying to get property of non-object in entity_metadata_user_access() (line 626 of /usr/local/www/***/sites/all/modules/contrib/entity/modules/callbacks.inc).

Commenting the following lines 625 out worked for me but seems like it could have adverse effects on other permissions - can anyone cast an eye over this and let me know what implications commenting it out may have

// Grant access to the users own user account and to the anonymous one.
if (isset($entity) && $op != 'delete' && (($entity->uid == $account->uid && $entity->uid) || (!$entity->uid && $op == 'view'))) {
return TRUE;
}

Status:Needs work» Needs review

Status:Needs review» Needs work

Please keep the status as is, #28

@Amitaibu We should key off the same "Enable Render Views filters as select list" setting the entityreference already provides? I looked through the code but didn't see a way to Add/Override a behavior plugin to use the same settings checkbox for OG.

thanx so much for the patch! I applied the patch as the instructions above with new 7.x-2.0-beta3 version.
select list appears but I get an:
"No valid values found on filter: OG membership: Group ID." error.
is this because of the latest version or was the patch applied poorly?

Patch still applies to the latest 7.1 version that's out, but actually trying to run the filter from views gives a time-out error. Any idea why?

Patch applies fine, receive this message with 7.x-2.0-beta4: "Notice: Undefined index: gid in views_handler_filter->accept_exposed_input() (line 1260 of /sites/all/modules/views/handlers/views_handler_filter.inc)."

And broken/missing handler for the Filter by Group ID.

Status:Needs work» Needs review
StatusFileSize
new3.07 KB
PASSED: [[SimpleTest]]: [MySQL] 745 pass(es).
[ View ]

Attached is a patch that adds the filter the way @Amitaibu suggested in #34. I'm pretty sure this is going to need some work, but I thought I would get things started. This works for me in the most typical case, but I'm not sure about some of the boundary cases and non-node group types. I also haven't checked access control. Someone with more OG code familiarity should review it.

This patch doesn't specifically check for the "render view filters as select" because I don't think it needs to. Even if that is turned off, the current textfield entityref filters don't work when you type in the entity_id. They do work once you apply this patch, as do the select filters.

In addition, after this patch, you can now use the og_group_ref field as an argument. Passing an NID in works as it should. I expect this is going to need some rework though, to make sure it's not too broad on entity type and obeys access control.

Status:Needs review» Needs work

Thanks for working on this zengenuity. Haven't tested but some review:

+++ b/plugins/entityreference/behavior/OgBehaviorHandler.class.phpundefined
@@ -162,4 +162,72 @@ class OgBehaviorHandler extends EntityReference_BehaviorHandler_Abstract {
+      if ($field['field_name'] == 'og_group_ref') {

Lets not hardcode the name. You can iterate over og_get_group_audience_fields()

+++ b/plugins/entityreference/behavior/OgBehaviorHandler.class.phpundefined
@@ -162,4 +162,72 @@ class OgBehaviorHandler extends EntityReference_BehaviorHandler_Abstract {
+              'node' => array(

This will also need to be removed. You can take the entity from the $field['settings']['target_type']

+++ b/plugins/entityreference/behavior/OgBehaviorHandler.class.phpundefined
@@ -162,4 +162,72 @@ class OgBehaviorHandler extends EntityReference_BehaviorHandler_Abstract {
+                'left_field' => 'nid',

Remove hardcode to nid. Use entity_info() to get the ID key.

Also can you add some comments about why you use "left_field".

Status:Needs work» Needs review
StatusFileSize
new2.44 KB
PASSED: [[SimpleTest]]: [MySQL] 745 pass(es).
[ View ]

Reworked the patch to remove hard-coded values. This should work with any entity type and field. I've tested with the standard node and user fields, and those work. More exotic configs should work, but I haven't tested them.

A couple notes:
1. We don't need to iterate over og_get_group_audience_fields(), because this gets called one field at a time. I'm using og_is_group_audience_field() instead.
2. The table we're joining isn't for the entityref target type. It's actually the base table of whatever entity type the field is attached to. It's possible to pull this from $field['bundles'], so I'm getting it from there.

This looks really nice! I'm seeing an error when I enable Render Views filters as select list via admin/structure/types/manage/post/fields/og_group_ref, which is probably the last piece in the puzzle. Looking forward for your next patch :)

I just spent some time testing, and I don't see an error when I enable or disable Render Views and filters as select list. Can you give me more information?

Status:Needs review» Fixed

@zengenuity , re-tested and it worked fine. Might have been working on a wrong branch. Anyway, awesome work -- committed.

Thanks. I'm excited for this patch for the argument handling even more than the exposed filter. It's now possible to build a view that shows group content for a group without adding any relationships. Same with listing users in a group. One thing I should mention on that: my patch does not check that the state of the membership is 1. Adding that would be easy, but I found that I was able to use filters to limit by OG membership state, so it's more flexible to leave it out. Just making sure you're aware of it, in case it's an issue for you.

I haven't tested the patch (or dev version of the module) but how would Amitaibu feel about adding the ability to show group content AND the group node itself (maybe an option on the argument)? That's a problem I always run into. When users want a list of all content in a group they assume the group itself is a member of its own group.

I should add: thanks so much for your work, zengenuity!

I've been following this thread, because I want to be able to select from which group to show al users in a view. And so now that the patch (#41) has been committed, I updated OG and... no selectlist available when using an exposed filter for filtering groupmembership. So, I guess this patch does something else? Well, my bad understanding of the english language and/or drupal/og/views shows again (that happens sometimes:).
Anyway, is there a way to accomplish what I want (I've got a view which shows all users, and I'd like to filter by groupmembership)? Any help would be very much appreciated.

Thanks,

Mike.

@sportel: Make sure you have Render Views filters as select list checked in the field properties for the og_group_ref field.

@azinck: That's not going to be possible, because there's no entry in the og_membership table relating groups to themselves. You could use a Views attachment, where the attachment shows the group. Will force it to always be at the top, but it could work for certain circumstances.

Yeah, I know there's no entry in og_membership...wondering if we can't tweak the argument handler to do something clever with some extra logic in the join and/or where clause since we've now got our own custom argument handler... I've got to play with it a bit.

> Just making sure you're aware of it, in case it's an issue for you.

Yap, that's how it should work -- it should be configurable.

Thanks for your response. And forgive me for being such a noob, but I can't find the checkbox you mentioned.

I made a view based on Users. I didn't make any relationships. I've added the fields: User: Name and User: Picture. And I've added the filter: User: Groupmembership (og_user_node). I thought this would be the field where I should have the options you mentioned when I expose it. But I don't. I'm probably doing something wrong, but don't know what. Can you help me out?

Thanks,

Mike.

It's in the field settings for users. admin/config/people/accounts

The direct path to the field settings is: admin/config/people/accounts/fields/og_user_node

Thanks, works perfect!

I absolutely didn't think of checking out the fieldsetting on the useraccount form. Thanks.

Mike.

Would it be possible to add the patch from #16 to the 7.x.1.x branch? I've been using it since July, and now I have to reapply the patch after every module update.

Status:Fixed» Closed (fixed)

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

Status:Closed (fixed)» Needs review

Bump.

Status:Needs review» Closed (fixed)