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'd like to have a select box exposed filter for all organic groups. How do I do this in Views? I only see the data entry option -- no end-user is going to understand that or know the group id.
View is User based.
Comments
Comment #1
mstef CreditAttribution: mstef commentedtrying to figure this out right now as well..
The only issue I see with this is the potential to have private groups - since the drop-down would have to restrict showing private groups that the current user cannot see.
Comment #2
markabur CreditAttribution: markabur commentedI was looking for the same thing -- I have a list of users and would like to filter it so it only shows members of a certain group, and I need the filter to be a dropdown select list, not a field where you have to type in the group ID.
Comment #3
jessico CreditAttribution: jessico commentedHere is what worked for me:
Admin > Configuration > Account Settings > Manage Fields > Edit the OG Reference (og_group_ref in my case). Under Additional Behaviors, I had to check the "Render Views filters as select list" box.
Then in Views -
1.) Add a relationship for OG membership: OG membership from Node
2.) Add a relationship for OG membership: Group Node from OG membership that uses the relationship OG membership from Node.
3.) Add the filter criteria Field: Groups audience (og_group_ref) and expose it to visitors
4.) Configure the filter to your preference.
(Additionally, I use Better Exposed Filters to make my drop down filters in Views a little more aesthetically pleasing.)
I'm still trying to get my mind around how OG 2.x and Views interact. I wish that I could provide a more elaborate response, but hope this is somewhat helpful.
Comment #4
markabur CreditAttribution: markabur commented@jessico -- thank you! Totally forgot about the "Render Views filters as select list" checkbox in the field settings... that's what I was looking for!
Comment #6
idcm CreditAttribution: idcm commented@jessico -- Thank you!
Comment #7
TravisJohnston CreditAttribution: TravisJohnston commentedThis is old but still applies to newer versions of OG and Drupal. I followed the directions in #3 and was able to get this working, but only partially. This does not work as expected if you are using Groups and Sub Groups like I am.
I am creating a calendar for a district website that acts like a multisite with OG. The District is the top level group, with each School in the district as subgroups.
This filter only looks at the top level group, so if I toggle District, the events show, if I only toggle a School, no events show.
Comment #8
TravisJohnston CreditAttribution: TravisJohnston commentedNevermind, I fixed it by instead I used:
Comment #9
faite CreditAttribution: faite commentedHey guys,
So I can get this exposed filter populating my groups, but only when the user type has the "edit group" or "administer group" permission set for that group type. What can I do so non logged in users can filter content by group? All the content is open and free to look at so I know thats not the reason.
Anyone else run into this issue or have any idea how to utilize the exposed filter dropdown without being an admin?
Thanks!