Drupal 8 development icon

Building Community Sites in Drupal 8: A Guide To D8 Modules For Community Support Sites

Mike Potter, Software Architect
#Development | Posted

Drupal 8 Introduction

Drupal 8 is a very flexible framework for creating a Community support  Site.  Most of the functionality of the community site can be achieved via custom content types, views, and related entities, and by extending various core classes.  You no longer need special-purpose modules such as Blog or Forum.

This blog will introduce several useful modules in Drupal 8 that are typically used when building a community site.

 

Segmenting the community into Groups

The key module in any community site is responsible for subdividing the users and content into smaller groups or sections. Moderation of content in a group is often assigned to a specific collection of users. Users can join a group to contribute or discuss content.

Drupal 8 has two competing modules for splitting a site into Groups:  Group and Organic Groups (OG). While both also existed in Drupal 7, several architectural changes have been made in D8.

The Group Module

The Group module makes flexible use of the Drupal entity system. Each Group is an entity, which can have multiple bundle “group types”. Any other entity, such as a Node can be associated with a Group via a relationship entity, confusingly called a “group content” entity. Note that the group content entity doesn’t contain the content itself, it is merely an entity that forms the relation between the group and the actual content. The “gnode” submodule provides the group content entity for Nodes.

Each group has a set of roles and permissions that users can be assigned to. Pre-created roles include “admin”, “member”, “outsider”, and “anonymous”. For example, members of a group can be given permission to create or comment on content. If a user is not assigned as a member (outside or anonymous) they might be able to view content but not add or discuss it.

A patch (issue #2736233) adds the “ggroup” submodule which provides the group content entity for groups themselves. This allows one group to be added to another as a “subgroup”. You can currently map roles between the parent group and the subgroup, but you cannot directly inherit users from the parent group; users must also be added to the subgroup.

Because any entity can be related to a group via a custom group content entity, this module is highly flexible and customizable. Various patches and submodules are available for associating menus, domain names, notifications, taxonomy terms, and other entities to a group.

The Group module is under active development and currently has an RC1 release, with a full stable release expected shortly.

Organic Groups

The Organic Groups (OG) module was very popular in Drupal 7 and even used as the basis for the Open Atrium distribution. Many people were not aware that OG was being ported to Drupal 8 because the development was done in Github, away from the normal drupal.org project page. OG is also under active development, but no releases have been made; just a develop branch is available.

In OG, any Node can be marked as a Group. So a group is still an “entity”, but it is specifically a node entity. OG also has roles and permissions, such as “member”. However, when a user is added to a group, a og_membership relationship entity is created. Node content is placed into a group via a simple entity-reference field on the node, pointing to the group node that it belongs to.

A github issue is available to allow a Group to belong to another group (subgroups), but it is more complex than simply adding an entity-reference field from one Group node to another. No concept of role mapping or user inheritance is available, nor is it planned.

While OG was used extensively in Drupal 7, its lack of releases and its more complex architecture has led many sites to start using the Group module instead, which has a more consistent framework for developers who need to integrate other entity types.

 

Subscriptions and Notifications in Drupal 8

To engage users on a community site, it must be easy to subscribe to interesting groups, content, and other users. The Message API module stack has been ported to Drupal 8 and provides the underlying message framework and email notification systems needed to tell users when their subscribed content has been added or updated. Phase2 has heavily contributed to the development and enhancement of the Message stack in Drupal 8, including the  Message Digest module that allows email notifications from Message Subscribe to be grouped into daily or weekly digests.

Flags

The message subscription feature uses the Flag module, which is also a key module on most community sites. In Drupal 8, a Flag is a fieldable entity. The ability to add custom fields to a flag makes them even more useful than in the past. For example, the Message Digest module can store the frequency of digest (daily, weekly, etc) as part of the subscription flag itself.

Rating Content

Community sites often contain a huge amount of content, and tools to help users sift through this content are needed. One way to find the most useful content is to allow users to “rank” content, either with a numeric rating system, or just a simple like/dislike. While a Flag could be used to mark a node as “liked”, the Rate module provides a more flexible mechanism, allowing you to choose between different rating systems, all using the Vote API module.

Since Comments are also entities in Drupal 8, you can rate comments, list them in ranked order of relevance, and even add a Flag for marking a specific comment as “the right answer”.

Rewarding Users

To reward your most active users, a “point system” is often used. Users who post correct answers, or have the highest rated content earn more points. Adding this and other gamification features to your site can encourage the growth of a vibrant and active community.

You can add a custom Point field to the User entity in Drupal 8 and write some rules for adding (or subtracting) points based on various conditions. With Drupal 8's flexible framework, you can easily integrate third party gamification features into your platform as well.

 

Community Content

Community sites live and die by having useful, engaging, and relevant content. Sites will often have several different types of content, such as articles, blogs, events, documents, etc. If you try to use a module dedicated to a specific type of content, you’ll often need to override or customize behavior. In most cases it is more effective to simply create your own content type, add some custom fields, and create some views.

Take advantage of the object-oriented nature of Drupal 8. If you need a new field that has slightly custom behavior, simply extend a base field class that is close to what you need and modify it. Don’t be afraid of some custom development to achieve the specific needs of your site. Since you can often just inherit base classes from core, it’s easier to write simple and secure extensions.

 

Conclusion

Every community site is different. How you best engage your community is greatly dependent on the content that is created, and by providing good tools to create and manage that content. But each community has unique motivators. Rather than using a one-size-fits-all product for your community, analyze and understand your specific requirements and prioritize those that best engage your users.

Most of the modules described here are under active development. Many do not have full stable releases yet in Drupal 8, but this is improving rapidly. If you see functionality close to your needs, get involved and help contribute to a module to make it better.

In Drupal 8 it’s even easier than ever to use the enhanced core functionality along with some basic modules to achieve your needs.

Interested in learning how to speed up your support team with community content management best practices? Check out this blog!

Mike Potter

Mike Potter

Software Architect