Complex workflows and multiple authors for Drupal nodes

A very common scenario: You have several users with different specialities who need to write nodes for your website. You have their colleagues who want to be able to comment on whatever they have written. Their supervisors wish to be able to look over their work before it gets passed through to your dedicated web editor/publisher. Individual users want their own task managers with only the pages related to them (in their capacity as author, viewer or approver), and their current tasks listed.

Oddly enough, this seems to be rather difficult to achieve with Drupal. There’s a Workflow module which lets you do something similar with user roles, but associating individual users with individual nodes is not something that’s intuitive using Drupal.

In the end, after researching lots of different modules which dealt with similar almost-but-not-quite things, I ended up using the revision moderation module and the 3 great building block modules of Drupal 6: Taxonomy, CCK and Views:

  • Taxonomy in order to create a workflow vocabulary with statuses to categorise nodes.
  • Revision Moderation to allow new unpublished revisions (with different workflow statuses of course) to be saved.
  • The CCK user reference module to save user ids, so a CCK user reference field might be created called “Authors”, taking multiple UIDs as inputs, ditto with Viewers and Approvers.
  • The Views module was then used to create ‘task manager’ views for users, taking their UID as input. So the task manager view retrieves the latest revision of all nodes which are currently unpublished and which have the current user’s ID stored in the Authors, Viewers or Approvers CCK fields.

In addition to this I created a very simple custom module which uses hook_node_form_alter and hides and shows various CCK fields based on their workflow status. The workflow taxonomy dropdown is always hidden, and instead the custom module added custom buttons linked to custom form submit functions, so for example a new ‘Save and send to Approvers’ would change the workflow status before the node was actually saved.

create snapshot

In this way a great deal of flexibility is possible without the addition of many extra specific modules. It feels like more of a Drupal way of doing things – pretty much anything is possible with Views, Taxonomy and CCK. Porting it over to Drupal 7 should be fairly easy too. You can read a more detailed write up on the Drupal website, here:

Leave a Reply

Your email address will not be published. Required fields are marked *