Organic Groups is quite flexible, and while we’ve been showing a more standard approach to using groups on a website, OG’s uses are only limited by your imagination. For example, for the initial launch of Modules Unraveled, I created a group type called “Video Series”, and group content types “Free Video” and “Member Video”. This way, when people purchased access to a series, they were automatically added as a member of the “Video Series” group, and given access to the specific fields that displayed the video and text, while the preview thumbnails etc. were only visible to non-members. That was all achieved using field access. Let’s take a quick look at how we can add a completely new group type that has its own group content content types using the scenario above as an example.
Create the “Video Series” Group Type
- Go to “Structure => Content types => Add content type” (admin/structure/types/add)
- Name: Video Series
- Comment settings: Hidden
- Organic groups: [x] Group
- (Save)
Create the “Member Video” Group Content Type
- Go to “Structure => Content types => Add content type” (admin/structure/types/add)
- Name: Member Video
- Organic groups: [x] Group content
- Target type: Node
- Target bundles: Video Series (This means that a “Member Video” can only be posted to a “Video Series”, and not to a “Group”.
- (Save and add fields)
Edit Groups audience field
- Click “edit’ next to the “Groups audience” field
- [x] Entity reference prepopulate
- Target bundles: Video Series
- (Save settings)
Add new field
- Label: Video
- Field Type: Long text (You could use a media field, or file field, but I’ll just paste some embed code.)
- (Save)
- (Save field settings)
- Text processing: Filtered text
- Default value:
- (Save settings)
- Edit the new field
- Default value: change the text format to “Full HTML” to make embedding easier
- (Save settings)
Create a “Video Series”
- Go to “Content => Add content => Video Series” (node/add/video-series)
- Title: Test Series
- Body: Lorem Ipsum
- Menu settings: Provide a menu link
- (Save)
Create a “Member Video”
- Go to “Content => Add content => Member Video” (node/add/member-video)
- Title: Test video
- Groups Audience: Test Series (You’ll notice that we can only select from groups of the “Video Series” content type.)
- Body: Lorem Ipsum
- Video:
- (Save)
Now we’ve got a video posted to our group, and we can configure the teaser view to show the fields that we’d like. And use field access to show and hide fields to and from non-members and members. And finally, we can use Panels to create a different layout for this Group type.
Configure a different layout for the “Video Series” Group type
- Go to “Structure => Pages” (admin/structure/pages)
- Click “Edit” next to “Node template”
- Click “Clone” next to “Group Layout”
- Variant name: Video Series Layout
- (Update and save)
- Click the “Selection rules” vertical tab
- Select “Node: type”
- (Add)
- [x] Video Series
- (Update and save)
- Click the “Content” vertical tab
- Remove the “OG Members” and “node:group group” panes
- Move the “Body” to the right region
- (Update and save)
Add “Node: type” selection rule to “Group Layout”
Now, in order to be able to use these both at the same time, let’s add the “Node: type” selection rule to the “Group Layout”.
- Click the “Group Layout” vertical tab
- Click the “Selection rules” vertical tab
- Select “Node: type”
- (Add)
- [x] Group
- (Update and save)
Now we can view our “Test Series” group, and see the new layout. And our original groups are still using the first layout we created. Now, we could create an entirely new set of default permissions for the “Video Series” Group type by going to “Configuration => Organic Groups => OG permissions overview” (admin/config/group/permissions) and clicking “edit” next to “Node - Video Series”. But, we’ve already covered how to do that in a previous video. This just demonstrates though, how each Group type can have completely different roles and permissions, as well as layout, and Group Content content types.
As you can see, Organic Groups is an incredibly useful and powerful module. If you master it, you’ll be amazed at the number of times you’ll tell someone “Organic Groups can do that!”