October 2008

Building a Publishing Workflow with Scheduled Transitions at Node Creation

Introduction

The Need

Our clients and other Drupal site administrators would like to use the Workflow module to schedule transition states in their publishing workflow.

The Problem

Currently, within the Workflow module a node cannot be assigned a scheduled state change upon node creation. A node must be saved first, then edited a second time by the user.

After reading this comment in the Workflow module issue queue: http://drupal.org/node/189572#comment-704334 I decided to try to add a little more automation to the process of creating a node and adding a scheduled state change.

In this Post

You'll learn how to create a publishing workflow for your website, and how to improve the process of scheduling a transition change during node creation.

Let's begin.

Note: This demonstration is build on Drupal 6. The process outlined below may be adapted for Drupal 5 install.

Install and Enable the Necessary Modules

1. Download, install, and enable the necessary third-party modules

o Workflow - http://drupal.org/project/workflow

o Token - http://drupal.org/project/token

o Token actions (part of Token module)

2. Enable Drupal's core Trigger module @ /admin/build/modules

clip_image002

clip_image004

clip_image006

Set Your Permission Settings

Allow at least one user role a permission to schedule workflow transitions @ /admin/user/permissions#module-workflow

clip_image008

Build Your Workflow

1. Go to /admin/build/workflow/add and add the workflow, giving it the title of "Scheduled Publishing"

clip_image010

2. After saving the workflow, go to /admin/build/workflow/ and click on "Add State"

clip_image012

3. Add the state name "Not Published". Leave Weight set to 0. Save.

clip_image014

4. Repeat steps 2 and 3 to add:

o "Create and Schedule Publishing" giving it a Weight of -1 to make it the first and default state after upon creating the node.

o "Published" leaving weight alone.

You should finish with the workflow sates as illustrated below:

clip_image016

Assign the Workflow to your Content type

In the illustration below, the workflow titled, "Scheduled Publishing" has been assigned to the "Blog" content type.

clip_image018

Build an Advanced Action

1. Go to /admin/settings/actions and scroll down to the form to "Make a new advanced action available"

2. Select the "Redirect to a tokenized URL" option and click "Create".

3. On the "Configure an advanced action" page:

o Give it the description, "Redirect to workflow tab of the node"

o Add the following tokenized URL: node/[nid]/workflow

o Save

clip_image020

clip_image022

Note: It is the use of this tokenized URL which helps automate the scheduled publishing choice after the node has been created. In a moment we are going to assign this action to a Trigger which fires after a new node is created. A redirect will occur to the Workflow tab for the newly created node (based on node id).

Edit the Scheduled Publishing workflow

Return to /admin/build/workflow/ and select the "Edit" link for the "Scheduled Publishing" workflow.

clip_image024

You will be taken to the "Edit workflow Scheduled Publishing" page shown below. On this page, you will choose what transitions each role may be allowed to initiate.

As illustrated below:

clip_image026

 

Authors may do these transitions -

  • (creation) to Create and Schedule Publishing
  • (creation) to Not Published
  • (creation) to Published
  • Create and Schedule Publishing to Not Published
  • Create and Schedule Publishing to Published
  • Not Published to Published
  • Published to Not Published

 

Blog users may do these transitions -

  • (creation) to Create and Schedule Publishing
  • (creation) to Not Published
  • (creation) to Published
  • Create and Schedule Publishing to Not Published
  • Create and Schedule Publishing to Published
  • Not Published to Published
  • Published to Not Published

 

While on the same page, scroll down to the "Workflow tab permissions" section, and select which roles may have access to the workflow tabs on nodes which have the workflow option. In this case I have selected the author, and the Blog User role.

clip_image028

Assign Actions to Triggers

1. Return to: /admin/build/workflow and click on "Actions" under the "Operations" links for your workflow.

2. You will be taken to the "Triggers" page where you'll set actions to happen when transitions occur.

3. On this page, you'll need to assign a number of actions to a number of triggers. Mainly "Publish" and "Unpublish" post actions to the transitions between your workflow states. On the "Triggers" page, if the "Workflow" tab is not selected, click it now.
Following the list below, add the numbered transactions to the titled triggers.

Trigger: When blog moves from (creation) to Published

1. Publish post

2. Save post

Trigger: When blog moves from (creation) to Not Published

1. Unpublish post

2. Save post

Trigger: When blog moves from (creation) to Create and Schedule Publishing

1. Change workflow state of post to next state

2. Redirect to workflow tab of the node

Trigger: When blog moves from Create and Schedule Publishing to Published

1. Publish post

2. Save post

Trigger: When blog moves from Create and Schedule Publishing to Not Published

1. Unpublish post

2. Save post

Trigger: When blog moves from Not Published to Published

1. Publish post

2. Save post

Trigger: When blog moves from Published to Not Published

1. Unpublish post

2. Save post

Here's How it Works

The following is an example of publishing a node with the blog content type and the "Scheduled Publishing" workflow.

Go to /node/add/blog . You'll notice the following new section on your node add page:

clip_image030

Note: "Create and Schedule Publishing" is selected by default because you set its weight for -1.

Enter sample title and body text and then click "save".

You will be taken to the following page:

clip_image032

Note: In this example, the node id for the new blog post is 125. After saving the new blog post, the system redirected automatically to the following URL: /node/125/workflow .

This action was driven by the advanced action created a the tokenized URL.

clip_image034

Now schedule the content to be published at a future date. The node for this example will be published on Oct 28 2008.

After you hit submit, you will be taken to the blog post.

Note the message at the top of the page shown below which states: "Lorem ipsum dolor sit amet is scheduled for state change to Published on Tue, 10/28/2008 - 12:00am".

clip_image036

Bonus Tip

Check out the Workflow Pending view for a nice summary of pending workflow changes on your site: /workflow/pending

clip_image038

***Want more? I've got a session, Building Complex Application and Publishing Workflows, proposed for the upcoming DrupalCon in Washington, DC. Check out my proposal and vote me up!***

 

Comments

Thank you webmaster logo design | Website design
You certainly deserve a round of applause for your post and more specifically, your blog in general. Very high quality material
Nice Article, informative and interesting Vizyondaki Filmler | Fragman izle | Sinema
You'll learn how to create a publishing workflow for your website, and how to improve the process of scheduling a transition change during node creation. -------------------------- cissp training
Thanks for this info. Will be a barbie oyunlar? Gratis Barbie Gioco Giochi di Ben10 good reference.
this is a great reference. you definitely do some great work. i would love to learn more.church sound systems
When i come to this trigger, I only get "Change workflow state of post to next state"... Not the redirect workflow tab choice... Can you help me?
Hi We are Mayuri Multimedia and doing Web design Company. This blog Very nice blog, Wonderful posting and useful for web developers.. Thank you very much...
Hi thanks for the post it was wonderful, however, how about the site administrator when assigning a workflow state should choose a user who will handle the task and pass it on to the next state and assign the next user that task.
It was very help full post thank you so much for sharing.
I wuold like to thank you for the efforts you have made in writing this article, i just want to tell you just keep up the good work doing. seo techniques.
Absolutely helpful. Thanks..
he biggest visible change is th' home page. Inspired in part by Dave Shea's lovely blog, I wanted t' make me front page shorter. So now, I'm displayin' th' latest full post, with 9 previ'us titles only. This is all done with views (usin' th' awesome new "attachment" display type). as the trend keep on changing like , now technology has a varied trends to complete the task desired by us.
Absolutely helpful. Thanks..
Brilliant! Very useful information for me.
Brilliant! Very useful information for me.
Thank you for the tutorial
Really useful for a noobs like me, thanks!
Great post! Thanks a lot for given this?
Great! This helps =) Thanks.
Nice reference for me. Absolutely helpful. Thanks..
@janusman @tonier @Dr. D.C. Harrison - dentist I am very glad this was helpful to you. Best Regards, Sean
This is a great quick reference guide for noobs out there. *coughs* I'll pin this down. Thanks for this, Sean.
Wow, I can't speak too much.. Thanks...
good work. Super document. Thanks liseli
Great! This helps =) Thanks.
Hello John. Thank you. Best Regards, Sean
Nice!
Thanks for taking the time to discuss this, I feel strongly about it and love learning more on this topic. If possible, as you gain expertise, would you mind updating your blog with more information? It is extremely helpful and beneficial to your readers. Indonesia Traveling Tour

Post new comment

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • You can enable syntax highlighting of source code with the following tags: <pre>, <c>, <cpp>, <drupal5>, <drupal6>, <java>, <javascript>, <php>, <python>, <ruby>. The supported tag styles are: <foo>, [foo].

More information about formatting options

By submitting this form, you accept the Mollom privacy policy.
Stay Informed

Sign up now for the Treehouse Newsletter.