Blog Image Workflows Moderation

Workflows and Content Moderation

Workflows and Content Moderation – both modules presented in this article are add-ons that extend Drupal’s capabilities in the area of content management, revisions and adding custom statuses. 

Workflows and Content Moderation

Workflows and Content Moderation improve content workflows in Drupal 8. By default, the content in Drupal (Node) can be either published or not, since these are the available statuses. Admins can see and edit all articles. Normal users can view content marked as “published”. For small pages, as well as websites where content is updated rather infrequently, this usually works just fine. The issue is with websites with a lot of content that is updated often. Large editorial offices usually have more than one person working on a single text. Some of these people write articles, others add photos, while others accept changes, make corrections and publish finished posts. The Workflows add-ons can be helpful in situations where you edit the content on a page, but you haven’t finished making all the changes, and the content is not ready for publication – at this point, you can save this version for example as a ‘draft’. The text can be edited later, and users can see the old version until a new one is published. In the case of more complex workflows, where the path from sketch to publication is very long, this module can prove to be very useful. In a situation where a finished article needs to be approved by another person, you can use additional Content Moderation – setting statuses can be assigned to specific roles. An example is shown in the attached picture. You can see users such as SEO expert, content editor and publisher. The path from a sketch to a published version goes through 7 different statuses. First, the editor creates the first version of the post, which is reviewed by the content editor, who makes necessary corrections, and when the post is ready, passes it on to moderation. The moderator can either dismiss or accept the post. At this point,  SEO expert makes changes and adds keywords, descriptions, tags, as well as other things related to search engine optimization. When the post is ready, the editor adds photos or galleries, and the whole piece goes to final moderation, which is carried out by the user with the role of Publisher. Managing such a process in pure Drupal would be rather cumbersome, and in more complex cases it would be nigh impossible. This module enables each user to access the post at different stages of production and to change the status at specific stages. This makes the workflow more streamlined, as everybody can easily determine the stage they are at. All this can be achieved using the Workflows module.

workflow


Installation

Workflows is a core module, and it has not been an experimental module for several versions already. That means you only need to install it. While at it, you may immediately turn on the Content Moderation module, which extends the capabilities of the Workflows module and provides basic functionalities, which we will show below.

installation


Setup

The first thing you need to do to make the module work is to go to:
admin/config/workflow/workflows
then add your workflow. If the Content Moderation module is enabled, you will have one workflow type available – Content Moderation.

setup


The next thing that needs to be done is assigning a workflow to nodes or entities. If you create a custom entity with revisions, you can also take advantage of the workflows module.

module workflows


Currently, you can use two statuses: Draft and Published. If you need any more, you can add your own.
Let’s add a new status: Ready to Publish.

add state


By adding a ‘transition’, you can control when your new status will be visible on the list. For example, you want to be able to set Ready to Publish if the current status is ‘Draft’. Additionally, each ‘transition’ can be assigned to a different role. 

transition


You can see a new position:

transition


Now you have a properly set-up module. Go to the content tab and select an existing node or create a new one. You can immediately see an additional field with the select list and the current status of your post. 

module


What is more, all users with access to status changes will see a visible block with a status change form. You can easily change the current status in the frontend, along with a short note about what the change is about.

frontend


There is also a new view – Moderated Content, where you can see all pending versions. It is, of course, a view, so you can edit its appearance, content or filters if necessary.

filters


This is what the basic configuration of the module and adding basic functionalities, which may be useful while working on your website, look like.


Revisions and sketches

latest version

Let’s now take a closer look at the editor view, as well as functionalities and tools offered by the Workflows module.
At first glance, you can see a couple of new options.
View – here you can see the latest published version, or in other words, what the end user sees. It may be older than what you can find in the Latest Version.

Latest version – here you can see a preview of the latest edited version, for example with draft status. This version is seen only by the admin. Regular users don’t have access to it. You can always go back to editing later on.
Revisions – update history, where you can restore previous versions.

revisions


Content Moderation Permissions

As I mentioned earlier, each role can have different permissions. This might prove useful, especially when you have many employees and many roles in the company, and everyone is responsible for a different aspect of work.
For example, let’s assume you have two roles – editor and moderator – and an example workflow:
Draft -> Ready-to-Publish -> Published.

This means a required status change:
Draft -> Ready to Publish.
You can give access to this action to a user with an “Editor” role. This will allow them to make corrections and changes; however, they will not be able to publish them.
Users with “Moderator” role might get access to changing status from
Ready to Publish -> Published.
Access to this option will enable them to publish the content, which will be available to all users.

Every status change can be assigned to a different role:

status change


Custom modules and API

By default, you get the Workflow and Content Moderation modules, but if you need something more specialised, you can create our own custom code.
Plugins – to expand the functionality of the workflow module, you need to create your own WorkFlowType. It must be an extension of WorkflowTypeBase class, here is an example of a definition of a plugin like that.
You should also check the code of the Content Moderation module and see what methods and classes it uses.

/**
* Attaches workflows to content entity types and their bundles.
*
* @WorkflowType(
*   id = "content_moderation",
*   label = @Translation("Content moderation"),
*   required_states = {
*     "draft",
*     "published",
*   },
*   forms = {
*     "configure" = "\Drupal\content_moderation\Form\ContentModerationConfigureForm",
*     "state" = "\Drupal\content_moderation\Form\ContentModerationStateForm"
*   },
* )
*/


Workflow module – Workflows without the S

There is an alternative version, which can add the same functionality to your website.
It is very easy to confuse the Workflow module with Workflows, which is available here on Drupal.org.
https://www.drupal.org/project/workflow, is a contrib module known from Drupal 7.
The module works in a very similar manner. When you need similar functionality, but for some reason, the core Workflows isn’t suitable, you might want to try this solution.
The workflow module has several sub-modules and is a bit more complex, which means it can satisfy more demanding users.

module workflow

Summary

As you can clearly see, Drupal is constantly evolving and new functionalities are constantly added to the core, along with solutions that enable you to change the purpose of your website with a few clicks and make your work easier. The example of Workflows and Content Moderation simply shows how additional modules can improve and streamline working with Drupal 8. The path of a post from a sketch to a published version is presented clearly. With additional statuses, every employee knows when and where to do their job. Workflows and Content Moderation will be a perfect fit for editorial offices, information websites and other outlets, where content is prepared and edited by numerous people or large teams. The possibility of assigning employee roles, such as moderator, SEO expert, editor, publisher and so on streamlines the work, reducing the probability of downtimes or making a mistake while creating content. Therefore, if you are looking for a similar solution for your website, it is definitely worth taking a look at Drupal 8 + Workflows.

If you do not know what to chose, you can always contact us. We are a Drupal agency and we do a lot of Drupal consulting. Building websites over the years we have encountered many various use cases nad workflow setups in Drupal.

We also encourage you to read other articles on our blog!

As part of Drupal support, we maintain existing websites and expand them with new functionalities