Welcome to the Geeks & God Static Archive. Read more »

Drupal 7: Organic Groups and Panels

User Rating:
Average: 4.2 (6 votes)

This video will walk you through how to set up Organic Groups in Drupal 7, and use Panels to display your group content.

Install and enable modules

Install Modules

  • CTools
  • Organic Groups
  • Entity
  • Panels
  • Views

Enable Modules

  • Chaos Tools
  • Page Manager
  • Views Content Panes
  • Organic Groups
  • Organic Groups Access Control
  • Organic Groups UI
  • Entity API
  • Panels
  • Views
  • Views UI

Rebuild Permissions

Create and configure a "group" type

Add Content Type

  • Name: Group
  • Description: A group can be public or private.
  • In the "Group" tab: Group Type, Not a group content type
  • (Save content type)

Configure field settings for groups (Configuration => Group field settings)

  • Add Field: "Group visibility" to group bundle
  • (Optional: Change default visibility to "private")
    • Manage fields for group content type, edit group visibility, change default to private.

Create Group

  • Title: Test Group
  • Body: This group will be private
  • Either
    • Set group visibility to private (anonymous users can not see the group)
    • or
    • Set group visibility to public (anonymous users can see the group)
  • Save

    View the group
    You will notice that anonymous users can or cannot view this group based on your visibility setting.

    Create and configure a "Group Content" type

    Enable Article to be posted to a group and be private (Configuration => Group field settings)

    • Add Fields: "Group audience" and "Group content visibility" to Article bundle

    Edit "Article" content type

    • In the "Group" tab: Not a group type, Group content type

    Set group content visibility to default to be private

    • Manage fields of the type "Article"
    • Edit - Group content visibility
    • Change default value to Private

    This only affects the content when it is associated with a group, else it is public

    Create Article

    • Title: Test Article
    • Body: This is the body of the article.
    • Groups audience: You have two options here
      1. Select a groups (or groups) to which your article should be available (Article is posted to the group and optionally public areas, depending on what you choose in the next step)
      2. Do not select any groups (Article is posted to generic locations only, such as the default homepage)
    • Group content visibility: You have three options here
      1. "Use group defaults" (I haven't had any luck with this option, if you know how to use this effectively, please post in the comments below)
      2. "Public" This will allow ANY user, anonymous or authenticated, to view this post (Note that even though you have selected a "Group audience" above, if this post is included in a view elsewhere on the site (such as the default homepage or a custom view) it WILL be displayed to ALL users of your site.
      3. "Private" This will allow only members of the group selected above to view this post (It will be included in the list of nodes on the group homepage (we will set that up in just a minute) and any views elsewhere on the site (again, such as the default homepage or a custom view).)

    View the article
    You will notice that anonymous users can or cannot view this article based on your COMBINED group and visibility settings.

    Configure Panels to display group content

    Panel Node template override

    • Go to Structure => Pages
    • Enable "Node template" then click on edit link
    • Click on the "Add variant" link
      • Title: OG Panel
      • Check both "Selection rules and Contexts" then click the "Create variant" button
    • Select "OG: Node is a group" from the menu drop down then click Add
    • Under Node, check is "Group content" node, then click Save
    • Click Continue
    • Under Relationships, choose "Group from node"
    • Click Add Relationship, then click Finish
    • Click Continue

    OG panel content layout

    • In this section we will layout our panel with two columns 25/75 for our group content.
    • Select flexible as the panel layout and click Continue
    • (Optional) Check the "Disable Drupal blocks/regions" checkbox
    • Click continue
    • Click on the "Show layout designer"
    • On the panel click on the "Row" link and select "Add region to left"
    • Name it "Left Region" then click Save
    • Resize the left region to about 25% with your mouse by dragging the bar between the Left and Center regions
    • Click on the "Hide layout designer" button
    • Click "Create variant"

    Add content to panels
    It's time to populate our newly created panel layout with our group related content

    Left region content:

    • Click on the gears icon to the left of the left region then click "Add content"
    • Select the Node category form the left
    • Select "Field: Group type (group_group) - options buttons"
      • Override the title (But leave it blank)
      • Change the formatter to "Group subscription"
      • Click Continue and Finish
    • Click the gears icon to the left of the left region again and click "Add content"
    • This time select the "Views panes" category from the left
    • Select "og members" and use Block for view display
    • Click Finish

    Center region content:

    • Click on the gears icon to the left of the center region then click "Add content"
    • Select the Node category from the left
    • Select "Node content"
    • Uncheck "Link title to node"
    • Select "Full content" for Build mode
    • Click Finish
    • Click on the gears icon to the left of the center region then click "Add content"
    • Select the "Views panes" category from the left
    • Select "og nodes" then Continue
    • (You may choose to override the title)
    • Click Finish
    • Save your panel by clicking on "Update and save" button.

    View your group page

    Final touches to clean up the group display

    • Go to Structure => Content Types

  • Manage display for "Group" type
  • Hide the fields "Group Type" and "Group visibility"
  • (Save)

    Decide who can post to your groups

    • Click on the "Group" tab for your group. You will see a "Permissions" link. It is currently read only because it is using the default group permissions.

  • The default group permissions can be set at "Configuration => Group global permissions" or "admin/config/group/permissions". Here you will see a couple of things: The roles across the top, and the permissions available across the left side.
  • You have a "non-member" role, a "member" role and an "administrator member" role. (These are similar to the site wide anonymous, authenticated and administrator roles, but are specific to groups). You can add more roles just like you can site-wide and we'll get to that in a bit.
  • As far as permissions go, if you would like all groups to have the exact same permissions, simply set the permissions here, and you are done. If you would like a group (or groups) to have different permissions, keep watching.

    • Back in the group tab of our group, click the permissions link to see what they are. You'll notice they are the same as those set in the global permissions.

  • One thing you will notice is that we only have permissions to edit and delete an article. This means that we cannot control who can post an article to this group. If they are a member, they can post to the group.
  • If you want to limit who can post to your group, and what they can post to your group, you will need to install the add-on module "Og Create Permissions", which can be found at drupal.org/project/og_create_perms.

    Once you have this module installed, when you return to your group permissions you will notice a new heading "OG create permissions" with your content types listed below. In this case, we only have "article". At this point no one can post anything to your group. You could set the global permissions to allow "administrator members" to post an article to your group, but you might not want that for all groups, and/or you might want a user to be able to post an article to the group, but not give them all of the additional permissions that comes with being an "administrator member".

    This is when you would want to create a new role.

    • Add a Group Role
    • Navigate to Configuration => Group field settings
    • Add the field "Group roles and permissions" to the "Group" bundle. This will add a new field to our groups.
    • Return to your group, and chose the edit tab.
    • Select "Override default roles and permissions". Now when we select the "Group" tab, the (read only) text is gone. This means we have effectively over-written the default values, and can change them to suit our needs.

    Create a new role for this group

    • Select "Roles".
    • Type in "Content Creator" and select "Add role".
    • Return to the "Group" tab and select "Permissions". Now we see that we can edit the permissions for this group, and that our new role has been added.
    • Under "content creator" check the box next to "Article: Create new content". (You may also want to allow them to "Edit own Article content" and/or "Delete own Article content". You could also create a "content moderator" role with the edit any and delete any permissions).

    To test this we can add a user to our group.

    • Create a new user.
    • Navigate to the "Group" tab, and this time select "Add People".
    • Add the user(s) you would like to be a member, and select "Add users".
    • Back in the "Group" tab, select "People".
    • Add the role "content creator" to your new member. (Caveat below in case you forget to do this).
    • Log in as that user, and now when you create an article, you can select to add it to the group.