Comments, reviews and content moderation workflows
The Urban Hipster Drupal Commerce demo site was built to showcase what Drupal 8 and Commerce-related modules can do. While the main focus has been Commerce, I recently started enhancing the site's content side, mainly the blog. After all, Drupal is a content publishing platform at its core, so why not show how content and commerce can work on the same platform together. In the ecommerce world, that’s actually a pretty big deal!
In this Tech Talk video, I’ll show you how the Drupal core Comments module is used for blog commenting and product reviews. I also go into detail on how you can configure a role-based publishing workflow using core’s Workflows and Content Moderation modules.
Comments and reviews
All of the blog posts and products on the demo site use the core Comments module for customer feedback. This allows any level of user (anonymous, authenticated, etc.) to add comments or reviews to these content items. The configuration and permissions for the Comments module control whether or not the comments need to be approved by an administrator before they appear on the site. When logged in, an administrator who has permission to manage the comments can use both the frontend interface as well as a backend interface for deleting, approving, editing and finally replying to the comments.
Like any content entity in Drupal, comments are fieldable. This means that you can configure fields to allow for additional functionality for your comments. It’s not covered in this video, but it’s worth mentioning that this is how I was able to get a 5-star review system easily integrated into the product comments.
Content moderation workflows
Drupal core also has a couple of modules for letting you define a process for adding specific types of content to your site. The Urban Hipster blog is now set up to be an example of this.
The first aspect to configure is the workflow. Workflows is where you determine what content will make use of the workflow, the “states” that the content will transition through, and finally, the transitions that can happen at any given state. These things all need to be configured first before moving on to permissions.
The second aspect is assigning role-based permissions to use the workflow. Permissions for workflows are found in the usual permissions backend page where all other permissions are set. Each workflow transition has permission attached to it and so you just simply check the role that can perform each transition. You can create new roles if you need to.
View the live example
As mentioned, the Urban Hipster Drupal Commerce Demo is an example of what can be done. Try it out yourself and see what you think. Here are some username/password combinations that will let you check out the workflows in action. The site refreshes every night so you don’t need to worry about breaking anything.
Role-based workflow logins:
- Blog author: blogauthor/blogauthor
- Blog reviewer: blogreviewer/blogreviewer
- Blog publisher: blogpublisher/blogpublisher
Administrator login (for viewing the configuration):
- Administrator: demoadmin/demoadmin