In order for a content type to show up in the “Content create links” area, we need to configure each content type. Let’s configure the “Article” content type for that now.
- Go to “Structure => Content types => Article => Manage fields” (admin/structure/types/manage/article/fields)
- Click “edit” next to “Groups audience”
If we scroll down just a bit, we’ll see the “Additional Behaviors” section. In here, we need to enable the “Entity reference prepopulate” option for this content type to show up in our “Content create links” list.
- [x] Entity reference prepopulate
- Action: Do nothing (We have a few options here, and you’ll want to make sure that you choose the action that is best for your content type and site. I’ll demonstrate each option in just a minute.)
- [ ] Apply action on edit (This sets whether the action should still be applied when editing the content. We’ll take a look at how this works in just a minute.)
- Fallback behaviour: Do nothing (This is what will happen when no values are provided via URL, for example, when a user goes to “Content => Create content => Article”. I’ll demonstrate these in a minute as well. “Do nothing” will leave the field alone, and editable as usual.)
- Skip access permission: - None - (It might be useful to set this to “Administer Content”, and I’ll do that in a minute, but for the sake of demonstration, I’ll leave it set to none for now.)
- (Save settings)
Now, let’s head back to our group and see if our create links are there. Sure enough, there they are!
Now, I’ll click “Article” to post a new article to this group.
When we scroll down, you’ll see the “Groups Audience” section with “Group #1” automatically selected. Let’s change the “Action” and “Fallback behaviour” settings in the Article content type to see what our other options are.
Other “Action” Options
Hide field
- Go to “Structure => Content types => Article => Manage fields => Groups audience” (admin/structure/types/manage/article/fields/og_group_ref)
- Action: Hide field
- Fallback behaviour: Do nothing
- (Save settings)
Now, when I go back to the group and click the “Article” create link, the group field is hidden. However, if I go to “Content => Add content => Article” (node/add/article) I can select “Group #1”. This is because the “Fallback behaviour” is set to “Do nothing”, which leaves it editable. We’ll take a look at the other fallback options in just a minute.
Disable field
- Go to “Structure => Content types => Article => Manage fields => Groups audience” (admin/structure/types/manage/article/fields/og_group_ref)
- Action: Disable field
- (Save settings)
Now, when I go back to the group and click the “Article” create link, the group field is visible, but disabled. So the user will know that it is being posted to “Group #1”, but can’t change that setting. I’m going to go ahead and create an article to demonstrate the “Apply action on edit” setting.
Apply action on edit
- Title: Article #2
- Body: (Lorem Ipsum)
- (Save)
Now we can see the article in the group. If we edit it and scroll down, we’ll find that the “Groups Audience” field is now editable. You may want this to be the way it works on your site, but if you want the action to also affect the edit page, you’ll want to enable the “Apply action on edit” option. Let’s do that now.
- Go to “Structure => Content types => Article => Manage fields => Groups audience” (admin/structure/types/manage/article/fields/og_group_ref)
- [x] Apply action on edit
- (Save settings)
Now, if we refresh the edit page, we’ll see that the field is disabled, just like when we created the article.
Other “Fallback behaviour” Options
The “Fallback behaviour” will affect the field when no values are provided via URL, for example, when a user goes to “Content => Create content => Article”. Again, right now, it’s set to “Do nothing” and the field is editable when I create an article through the Create content menu.
Hide field
If we change the “Fallback behaviour” to “Hide field”, and refresh the create article page, we’ll see that the field is hidden. But if we click the “Article” link within a group, the field is still visible, but disabled as per the “Action” setting.
Set form error
If we select “Set form error”, we get an error that says “Field Groups audience must be populated via URL”. But we are able to select a group and save the article, whether we choose a group or not.
Redirect
Finally, if we select “Redirect”, we are redirected to the home page, and get a notice that again says “Field Groups audience must be populated via URL”. This means that no one can create an article unless it is being posted to a group, from within a group.
Skip access permission
Like I said earlier, you might want to set the “Skip access permission” to “Administer content”. I didn’t do that before so that I could demonstrate the other settings, but now I will.
- Skip access permission: Administer content (You could select a different permission, but this one makes sense to me.)
- (Save settings)
Now, because I have the “Administer content” permission, I can create content from anywhere, and select any groups audience that I’d like.
- Go to “Content => Create content => Article” (node/add/article)
Here you’ll see that I can now create an article, and select any group(s).
And if we head back to “Group #1” and click the “Article” create link, you’ll see that the field is enabled for me. So the “Action” and “Fallback behaviour” settings do not affect me because I have the “Administer content” permission.
_Remember: you’ll have to configure these settings for each content type that you want to display in the “Content create links” section of your groups, and each content type can have different settings, which is handy.