Group for Drupal

Tuesday, August 30, 2016 by Alec

When I first got introduced to Organic groups for Drupal 7, I was struggling. Particularly with understanding the concept of having nodes that carry content, being used as an entity, for forming groups. It worked, but it wasn’t done intuitively. It just didn’t make any sense to me.

Well, we have a new hero around the corner, who is going to save us from all the pain we had to go through in OG to get something to work in the way we wanted to. The name of it is Group and it’s ready for Drupal 7 and 8. Let me show you where the strength of Group is and where it defeats Organic Groups.

Simple? Very

Groups should be like content types. I want different kinds of groups with different fields, roles and permissions. That’s exactly how Group handles it. Before creating a group, you need at least one group type, in which you define fields and their displays just like you would in a content type. Using the same API as Drupal content types means, that anything you could do with fields in a content type, you can do in a group type. That means you already know, how this part of Group works. So you should feel very familiar with Group, even if you install it for the first time. Pretty awesome.

 

Manage fields

There are 3 predefined roles for every group:

  • Anonymous
  • Outsider
  • Member

The names are pretty self-explanatory. The anonymous role matches everyone who isn’t a logged user, the outsider is someone that is logged into Drupal, but is not a member of the group, and finally we have the members of the group. Just like you would expect you are able to define any number of custom roles that can be different in each group type.

Group content? Anyway you like it

Group content is any entity you want to attach to a group. By default, we only have one type of group content enabled and that is the membership entity of the members. You can define different group content for different group types and every group content item is fully fieldable. That’s right. You want a special kind of membership for a specific group type? No problem. Just put a couple of field on the membership entity and you’re good to go.

Group type

Basically anything you attach to the group can be fieldable. Another interesting thing about the relationship entity that sits between the group and the actual user/content is, that if you delete it from the Group interface, you are not deleting the content, but the linking entity instead, so the content (or user/entity/whatever) is left unchanged.

Powerful? No doubt

Every group type has their own group content types and every one of them has configurable permissions and fields. Basically, endless possibilities for any type of group you want. If you aren’t a stranger of coding on Drupal, you can create your own entity type and just plug them into the group content of a group that comes with all of its advantages. As I already mentioned, any group itself is an entity, so creating nested groups is not an issue at all.

Out of the box, Group integrates with Views, Rules, i18n, Title and I’m sure much more is coming. Built on top of Entity, API Group provides all of its benefits to developers.

Code? Clean

Just like Drupal 8 the Group developers decided to go the OOP way. This makes any code you write for Group much more understandable than what you had to write for Organic Groups, where all you were doing was googling for all the function names and hooks Organic Groups provided. With Group you have the group entity object, from which you call any method (hopefully in an IDE with autocomplete).

Entity

The fact that Group is coded in an object oriented way is great for developers, because they extend anything they like. Instead of using hooks, you just extend a method in any way you need and right away you have cleaner and nicer code that follows today’s trends. That doesn’t mean that hooks are not available. They are included in Group and are very well documented.

Still OG? No way

There is no doubt that Group is here to take the place of OG. It has everything that OG provides plus all the things that were missing. All brought in a neat UI, where you can configure so much without being a coder.

The only downside of Group I can think of currently is the state of the module. It’s currently marked as alpha, but seeing the growing number of contributors and downloads can only mean the development speed is increasing. It’s also hard to expect finding a lot of answers online, because Group is a very young module. Nevertheless, given very good response rates on the module’s issue queues I would say that writing a ticket is your best bet if you need any help.

Easy, powerful and extendable. It’s about time you give it a shot.