Drupal Tutorials and Blog Posts

Organic Groups: Social Networking for Drupal

[UPDATE] We now have a detailed video class covering all the important aspects of using Organic Groups.

Organic Groups (OG) is the social networking solution for Drupal. It forms the basis of http://groups.drupal.org and also powers Drupal Commons, the widely used social networking distribution.

OG allows users to create and manage their own groups. Other members can then join those groups and share content either privately or publicly.

Two notes of caution before we start:

  1. OG is a powerful solution but not for the faint of heart. To use it, you will need a good understanding of Drupal, plus Views and Panels as well.
  2. There are some major differences between the Drupal 6 version and the new Drupal version.

Here's an introduction to OG for Drupal 7. Click here for our tutorial on Organic Groups for Drupal 6.

Step 1: Install the Modules

tutuploadsmedia_1334102126879.png

You'll need to download and install these four modules:

Organic Groups won't work without those modules, but to make use of OG you'll certainly need these modules too:

When you visit the modules page to enable modules, make sure to enable all of the Organic group submodules.

After enabling the modules, you'll see a message saying "The content access permissions need to be rebuilt." Click "Rebuild permissions" and follow through the steps until the process is finished.

tutuploadsmedia_1334102622307.png

Step 2: Creating the Content

Here's the key thing to understand about Organic Groups: they are entirely based on Drupal's nodes.

The groups themselves are nodes and the content shared inside the groups are nodes. When you set up a new content type, you can decide whether nodes in that content type become groups or content within groups.

In this example we're going to build a social networking site for a school. We're going to allow parents and helpers to organize into groups.

  • Go to Structure > Content types > Add content type.
  • We're going to create a type of group called a "Volunteer Team".
tutuploadsmedia_1334344639581.png
  • Each node created using this content type will be a new group because we selected "Group type" in the options at the bottom of the page.
  • We also decided that this is "not a group content type".
tutuploadsmedia_1334103131628.png
  • Now let's create a group. Go to Add content > Volunteer team and create a new node.
  • Make sure to check the box Group to ensure that this node will form the basis of a new group.
tutuploadsmedia_1334102799545.png
  • The resulting node will look just like a normal content item. The one exception will be the Group tab.
tutuploadsmedia_1334102820180.png
  • Click the Group tab and you'll see a pop-up window. This allows you to control the members of the group.
tutuploadsmedia_1334102858912.png

Now let's create some content for our groups.

  • Go to Structure > Content types > Add content type.
  • We're going to create a type of content called "Events for Volunteer Teams".
tutuploadsmedia_1334103104481.png
  • Select "Not a group type".
  • Select "Group content type".
tutuploadsmedia_1334103158227.png
  • Save your new content type.
  • Go to Add content and select Events for Volunteer Teams.
  • Create a specific new event for one your volunteer team.
tutuploadsmedia_1334103214655.png
  • As before, your event will look like a normal content item. The only slight difference is that your asssociated group will be listed.
tutuploadsmedia_1334103769409.png

Step 3: Views

Currently we have no real information or layout for any of our group pages. We need to use Views and then Panels before our social networking site will take shape.

Go to Structure > Views and you'll see that four different views are already in place. These views will form the building blocks of your group pages.

  • OG content: this will show all of the content posted to a particular group.
  • OG list: this will list all of the available groups on your site.
  • OG members: this will show the new members of a group.
  • OG User groups: this will show a user which groups they have joined.
tutuploadsmedia_1334103798799.png
  • You can click on the paths for OG list and OG User groups to get an idea of what they'll look like.
tutuploadsmedia_1334103891045.png

Step 4: Panels

Now that we have our content and views, we can put them together using Panels.

  • Go to Structure > Panels.
  • Click Enable and then Edit next to Node template.
tutuploadsmedia_1334343396268.png
  • Click Add a new variant.
tutuploadsmedia_1334343524483.png
  • Enter a Title for your Panel.
  • Check the Selection rules box.
tutuploadsmedia_1334343547843.png
  • Select OG: Node is an OG group.
  • Click Add and then click Save.
tutuploadsmedia_1334343587346.png
  • Click Continue.
  • Choose a layout for your groups page.
  • Click Continue.
tutuploadsmedia_1334343666573.png
  • Click Continue and then click Continue to skip the next page.
  • Click on any of the cogs next to one of the regions:
tutuploadsmedia_1334343713600.png
  • You can choose to place some of the different node elements on the page.
tutuploadsmedia_1334343756917.png
  • You can also take some of the Views that we saw earlier and place those into different regions.
tutuploadsmedia_1334343772745.png
  • Click Create Variant (do not click Save at this point. If you do, you'll lose your work).
  • Click Update and Save.
  • Go to visit one of your groups and you'll see that groups pages are starting to take shape.
tutuploadsmedia_1334343879402.png

What's Next?

From this point onwards, there is still a lot of work to do in order to create a social site, but hopefully the principles are now clear. The process of getting OG setup is Content > Views > Panels.

Comments

 
Warren
#1 Warren 2012-04-20 00:18

Thanks for the tutorial.

I'm trying to understand why, or if, panels is required with OG. Most introductory example tutorials for OG use panels. Is it necessary?
 
 
steve
#2 steve 2012-04-20 13:12

Hi Warren

Yes, it's essential. Without Panels (or a similar solution) you wouldn't have any sort of a layout for the groups pages.
 
 
Kirol
#3 Kirol 2012-05-21 20:34

Is there any way I can make groups open and put them into an event page so users can apply for a Volunteering team? If so, how?
 
 
steve
#4 steve 2012-05-21 20:36

Hi Kirol

We've just released a whole videos series on Organic Groups with a lot of detail on permissions. I hope that would help: www.ostraining.com/.../view
 
 
DavidT
#5 DavidT 2012-06-09 12:05

I hate Panels and I love Display Suite -- can we in theory use the latter, or does OG force us into Panels?

Thanks
 
 
steve
#6 steve 2012-06-09 12:21

Hi David

No, not all. DS would be fine.

Our main Drupal teacher is a huge DS fan. Notice that we've got a Display Suite class but not a Panels class ;) www.ostraining.com/.../view
 
 
chukkitty
#7 chukkitty 2013-02-12 06:26

Dear All

My drupal is 6.22, I want create private group to member.
If I set the group to public , each member can see the page.
But I set the group to private, all member cannot see the page.
And the error message is

Access denied
You are not authorized to access this page

Is I miss some permission setting?

Best Regard
Kitty
 

Add comment


Security code
Refresh

blog-ad

Start Online Training

Members get access to all our video training. That's 1,142 training sessions in Joomla, Drupal, WordPress and Coding.

Latest Comments

The License for Our Tutorials

All of our tutorials are published under the Creative Commons Attribution-NonCommercial license. This means:

  • You can re-use these tutorials.
  • You can modify these tutorials.
  • You must link back to our original tutorial.
  • You can't use these tutorials commercially.

Click here to read the full license.

Open Source Training is not affiliated with or endorsed by the Joomla, WordPress or Drupal projects.
All product names and trademarks are the property of their respective owners.

Copyright 2013 Open Source Training, LLC. All rights reserved.