Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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?
Comment | File | Size | Author |
---|---|---|---|
#41 | og-filter-group-audience-select-1109676-41.patch | 2.44 KB | zengenuity |
#39 | og-filter-group-audience-select-1109676-39.patch | 3.07 KB | zengenuity |
#24 | og-1109676-24_add-filter-widget.patch | 1.96 KB | avr |
#16 | 1109676-16-og-group_audience_widget.patch | 2.41 KB | pfrenssen |
#13 | widget_to_filter_groups-1109676-13.patch | 1.75 KB | avr |
Comments
Comment #1
dpolant CreditAttribution: dpolant commentedI 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.
Comment #3
amitaibu> One thing I noticed was that og views api stuff is out of date
Can you provide a patch?
Comment #4
amitaibu> One thing I noticed was that og views api stuff is out of date
Can you provide a patch?
Comment #5
mherchelsubscribe
Comment #6
amitaibuViews integration was overhauled.
Comment #8
logii CreditAttribution: logii commentedHi 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.
Comment #9
mdroste CreditAttribution: mdroste commentedMaybe I miss something. I'm also not able to create an exposed filter dropdown by group audience for group content.
Comment #10
amitaibu> 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.
Comment #11
avr CreditAttribution: avr commentedThe attached patch allows for a selecting groups when using the "Field: Groups audience:gid" field.
Comment #12
mdroste CreditAttribution: mdroste commentedI can't see any difference after the patch. There is still no dropdown as an exposed filter for groups.
Comment #13
avr CreditAttribution: avr commentedI'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
Comment #14
mdroste CreditAttribution: mdroste commented@avr
Now it works. Great. Thanks for your work.
Comment #15
vikramy CreditAttribution: vikramy commentedThanks 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".
Comment #16
pfrenssenAwesome, 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:
Comment #17
mwallenberg CreditAttribution: mwallenberg commentedI 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?
Comment #18
eleonoreft CreditAttribution: eleonoreft commented#16: 1109676-16-og-group_audience_widget.patch queued for re-testing.
Comment #19
mwallenberg CreditAttribution: mwallenberg commentedStill working in 7.x-1.4.
Comment #20
bjlewis2 CreditAttribution: bjlewis2 commentedWhen I followed the steps above, I got this in the filter criteria:
And events that are posted to multiple groups show on the calendar 6 times (once for each group)
Comment #21
jessico CreditAttribution: jessico commented#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.
Comment #22
amitaibuLet's move it to 2.x. The filter should be adjusted to the fact we no longer have a single group, but different entities.
Comment #23
kclarkson CreditAttribution: kclarkson commentedI too am looking for this feature.
Does this mean the patch must be updated to work with 2.x ?
Thanks,
Comment #24
avr CreditAttribution: avr commentedHere'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:
You should now have a select list instead of a plain text box. Exposing the filter works as expected.
Comment #25
avr CreditAttribution: avr commentedUpdating to "needs review"
Comment #26
amitaibuThe patch is against 1.x, no?
Comment #27
avr CreditAttribution: avr commentedThis patch should be against 2.x. Just checked again - it applies. Perhaps I'm missing something?
Comment #28
amitaibuI think we should task another approach, in the line of
EntityReferenceBehavior_ViewsFilterSelect::views_data_alter()
@avr, is it something you can investigate?
Comment #29
avr CreditAttribution: avr commentedThanks 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.
Comment #30
magtak CreditAttribution: magtak commentedgetting same as #20. Broken/missing handler.
Comment #31
iaminawe CreditAttribution: iaminawe commentedThe 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?
Comment #32
iaminawe CreditAttribution: iaminawe commentedSorry 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;
}
Comment #33
sunildhimal CreditAttribution: sunildhimal commentedComment #34
amitaibuPlease keep the status as is, #28
Comment #35
rocketeerbkw CreditAttribution: rocketeerbkw commented@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.
Comment #36
asioren CreditAttribution: asioren commentedthanx 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?
Comment #37
Sherbet CreditAttribution: Sherbet commentedPatch 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?
Comment #38
Premier Andrew CreditAttribution: Premier Andrew commentedPatch 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.
Comment #39
zengenuity CreditAttribution: zengenuity commentedAttached 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.
Comment #40
amitaibuThanks for working on this zengenuity. Haven't tested but some review:
Lets not hardcode the name. You can iterate over og_get_group_audience_fields()
This will also need to be removed. You can take the entity from the $field['settings']['target_type']
Remove hardcode to nid. Use entity_info() to get the ID key.
Also can you add some comments about why you use "left_field".
Comment #41
zengenuity CreditAttribution: zengenuity commentedReworked 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.
Comment #42
amitaibuThis looks really nice! I'm seeing an error when I enable
Render Views filters as select list
viaadmin/structure/types/manage/post/fields/og_group_ref
, which is probably the last piece in the puzzle. Looking forward for your next patch :)Comment #43
zengenuity CreditAttribution: zengenuity commentedI 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?Comment #44
amitaibu@zengenuity , re-tested and it worked fine. Might have been working on a wrong branch. Anyway, awesome work -- committed.
Comment #45
zengenuity CreditAttribution: zengenuity commentedThanks. 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.
Comment #46
sportel CreditAttribution: sportel commentedComment #47
azinck CreditAttribution: azinck commentedI 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!
Comment #48
sportel CreditAttribution: sportel commentedI'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.
Comment #49
zengenuity CreditAttribution: zengenuity commented@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.
Comment #50
azinck CreditAttribution: azinck commentedYeah, 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.
Comment #51
amitaibu> 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.
Comment #52
sportel CreditAttribution: sportel commentedThanks 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.
Comment #53
zengenuity CreditAttribution: zengenuity commentedIt'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
Comment #54
sportel CreditAttribution: sportel commentedThanks, works perfect!
I absolutely didn't think of checking out the fieldsetting on the useraccount form. Thanks.
Mike.
Comment #55
JuliaKoelsch CreditAttribution: JuliaKoelsch commentedWould 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.
Comment #57
griz CreditAttribution: griz commentedBump.Comment #58
griz CreditAttribution: griz commentedComment #59
preksha CreditAttribution: preksha commentedHi,
As per #16, it works by group id, not by group name. Also, I am not getting any drop down when I expose the filter.
Any one has an idea?
Comment #60
Alan D. CreditAttribution: Alan D. commentedI just added a filter "Content: Groups audience (og_group_ref)", works without the relationship. Just remember to configure the field to show a select list.
Comment #61
preksha CreditAttribution: preksha commented@Alan
Yes, it works but need to configure the field to show a select list.
Comment #62
surendra77c CreditAttribution: surendra77c commentedAfter applying the path please do the necessary setting in views :
1 .Under RELATIONSHIP ( add )
OG membership: OG membership from NODE
2.Under FILTER CRITERIA
(OG membership from node) OG
membership: Group ID (exposed)
Note : select the above (1) relationship in configuration of filter criteria
Comment #63
rv0 CreditAttribution: rv0 commentedAs Alan D says in above comment #60, no need to add any relationship, nor to use the group id field.
just the plain "content: group audience" field exposed, works like a charm.
Comment #64
David_Rothstein CreditAttribution: David_Rothstein commentedNote: If you find that this feature isn't working for you - or if you find that you do in fact need to add a relationship to get it to work - you could be running into the problem in the linked issue. In any case, that issue is essentially a followup to fix a bug in this one.