I'm on d7. Im trying to figure out how to display all the nodes that are in an organic group. I feel like this is a major thing that the OG module should do and don't know why I cant figure it out. I have views installed and have looked at the OG content view, but it doesn't display anything when I test it with the preview filter. Ive seen a video on how to do this with panels, but I don't have panels installed and don't plan on it. Thanks for the help.
Here's how you can do it with views in Drupal 7. Create a new view of nodes as you normally would, but make sure you set up the appropriate relationship for it that will allow you to filter your nodes based on their group membership:
- Add a relationship (under the 'Advanced' section of the view)
- Select the 'OG membership: OG membership from Node' field, which is under the 'OG membership' section of the fields
- Mark this as a required relationship on the next screen if you don't want to include nodes/content that do not have a group
- Only after you've added that relationship will you be able to see the appropriate 'Group id' filter. Go ahead and add a 'Contextual filter', also under the 'Advanced' section and select 'OG membership: Group ID'.
- This filter will now allow you to input the Group Id as a filter to the view through the URL (test it with www.[your site].com/[your view path]/[group id]) or by figuring out which group you're currently in if you set the following screen properly for the contextual filter
- You can now test this in the view preview pane by entering in different OG id's and seeing that it should filter the list of nodes to ones only with those Groups set as their audience.
Let us know if this worked for you!!