
Drupal 10 Development Cookbook
By :

The Workspaces
module provides a new way of working with content on your Drupal site. It allows you to have a live version of your site’s content and parallel draft versions. Normal content workflows involve multiple pieces of content that may be drafted and published at various times. The Workspaces
module provides a way to create and prepare published drafts that release at the same time.
For example, during a big sporting event, articles are prepared based on whichever team wins. Once the winner is announced, that version of the site’s content can be published. In this recipe, we will install the Workspaces
module and walk through using site versions.
Important note
At the time of writing, the Workspaces
module is an Experimental
module. Modules that are marked as experimental are under active development and not considered stable. Experimental modules provide a way of adding new functionality to Drupal core more easily. You can read more about the experimental module policy on Drupal.org
: https://www.drupal.org/about/core/policies/core-change-policies/experimental/policy-and-list.
In this recipe, we will be using the Standard installation, which provides the Basic Page
content type. Any content type will suffice.
Workspaces
module:php vendor/bin/drush en workspaces --yes
The Workspace
module uses the existing revision capabilities of content entities. Revisions are then tracked against a workspace until they are published to the Live workspace. The Workspace
module also adds safeguards. Forms that manipulate site configuration cannot be saved unless in the Live workspace; the module displays a warning and disables the Submit button. When using multiple workspaces, the Workspace
module only allows a piece of content to be edited in one workspace.
Workspaces also have a user account associated with them. This allows segmented workspaces for specific users. This allows content creators to create a new workspace, but not view or modify another content creator’s workspace.
The Workspaces
module provides other user interfaces not covered in this recipe, and there is another way to use a workspace beyond just content.
Effort is being made to make the Workspaces
module stable. These issues are tagged in the Drupal core issue queue as WI critical (short for Workflow Initiative Critical). The list of issues can be found here: https://www.drupal.org/project/issues/search/drupal?status%5B%5D=Open&issue_tags_op=%3D&issue_tags=WI+critical.
When the workspace menu is open in the toolbar, you can click the Manage workspace link to see all of the active changes in the workspace. This makes it easier for a content manager to review what content has been modified in a workspace. It also allows for deleting those changes to revert to the original content.
This overview is useful for reviewing all the changes that may be published to the Live workspace.
A workspace may also have a parent workspace. This allows you to maintain a centralized Stage workspace but forces content creators to have their child workspace under Stage. All content modifications can then merge into Stage instead of each contributor’s workspace publishing to Live.
Drupal has a mechanism for determining the active theme, which, by default, is the default theme. Code can be written to override the current theme based on specific conditions. The Workspace Theme
module (https://www.drupal.org/project/workspace_theme) does just that.
It adds a new field to a workspace that allows you to specify a different theme to be used when that workspace is active. This allows you to preview a site’s redesign with a new theme without making it the default theme on the production site, or purely relying on a test server.
Drupal.org
: https://www.drupal.org/docs/8/core/modules/workspace/