Webscaped.com

Basic publishing workflow with Drupal 6

Sunday August 10th, 2008
Comment Icon 9 comments

Recently the workflow module has been released for Drupal 6. I thought I’d share a quick tutorial on how to make a workflow that:

Allows anonymous users to post news

Generate an email to site administrators

Redirect the anonymous user to a thankyou page.

Allow for site administrators to skip the above when they themselves post content.
For this, we’ll need the following:

I also have PathAuto enabled, to clean up my urls.

Make sure you have the Token, Token Actions and Workflow modules installed add enabled.

Create a news content type

Login as an administrator, click “Administer” and then “Content types”.
Click “Add content type” and then create a “News” type. Make sure “Published” and “Promoted to frontpage” are unchecked under “Workflow settings”. Save the new content type.

Now that has been created, lets allow anonymous users to add some news.
Click “User Management” and then “Permissions”
Under “Node Module” check “create news content” for anonymous users. Save the changes.

Now, if you logout, you should be able to add a news item. If you do this though, the following screen will appear:


Not too user friendly. We’ll create a workflow to change this.

Create a Workflow

Go back to the administer section, under “Site Building” click “Workflow”
Click “Add workflow”
Call it your new workflow “News Publishing”
Select the “News Publishing” workflow for the news content type.
Click “Add State”
Create an “Unpublished” state
Create a “Published” state
Select a weight of 5 for this one, since we want it to come after the “Unpublished” state.
Under News Publishing, click “Edit”
Allow author to go from creation to “Unpublished”
Allow Authenticated users to post from creation to published
Allow Authenticated users to go from “Unpublished” to “Published”


If not already checked, click “Authenticated User” under “workflow tab permissions”
Save your changes

Now lets add some actions to apply when news is changed from one state to another.

But first, lets make a thank you page, to display when a user has submitted content. Click on “Create Content”, and then “Page”.
Fill out the details, with a title of “Thankyou”, and some text in the body.

Save the content.

Create some actions

Lets make a redirect action.
Click on “Administer” and then “Actions” under “Site Configuration”.

At the bottom, use the drop down box to select “Redirect to url” then hit “Create”

Call it “Redirect after successful news posting” and enter “content/thankyou” for the URL. (You might need to change this depending on whether you have pathauto, and what title you put for the page you created earlier)

Hit Save.

Now we need an action to send the site administrator an email.

At the bottom, use the drop down box to select “Send a tokenized email” then hit “Create”

Enter “Unpublished news email notification” in the description, put yourself as a recipient.

Enter something like this in the message area:

Some news has been posted to your site.
 
Go to the following address to publish the news.
 
[site-url]/node/[nid]/edit

Hit save.

Assign actions to states

Ok. Our actions have been created. We need to go back to our workflow section and assign these actions to state transitions.

Click “Administer” and then “Workflow”

Click “Actions” next to our “News publishing” workflow.


Under “Trigger: When news moves from (creation) to Unpublished”
Select “Unpublished news email notification” and hit assign
Select “Redirect after successful news posting” and hit assign

Those actions now take place when the anonymous user creates news content.

Lets assign some actions for the site administrators.

Under “Trigger: When news moves from (creation) to Published”
Select “Promote post to front page” and hit assign
Select “Publish post” and hit assign

Under “Trigger: When news moves from Unpublished to Published”
Select “Promote post to front page” and hit assign
Select “Publish post” and hit assign

We’ll need to above so that news is published when it moves to the “Published” state. (Fairly straight forward)

All done.

Try it out, log out and submit some news. You should be redirected, and an email generated. Login in and edit the news just submitted. Change the state from “unpublished” to “published”. It will become published and show on the front page.

Ok, try extending the functionality. Using CCK, add an email field to the news posting form, and add an action to when a news becomes published to send an email to the author to confirm their news is now live on the site.

Related posts:

9 comments

  1. Frank

    Hi,

    Thanks for the information. I have followed your instruction i couldn’t seem to find the Action link next to the created workflow in Administer >> Site Building >> Workflow.

    Here is my setup:

    Drupal 6.10
    Workflow 6.x-1.1
    Workflow access 6.x-1.1
    Token 6.x-1.11
    Token actions 6.x-1.11
    pathauto 6.x-2.x-dev
    Rules 6.x-1.0-beta5

  2. Frank

    Ignore my previous post. Figured it out. thanks a lot!

  3. Michael

    I’m guessing that the Trigger module needed enabling. :)

  4. Dennis

    Hi, first thanx for all the good things found here !

    I’m encountering a problem by following the tutorial : everything is ok but the tokenized email doesn’t works.
    All actions are triggered (log says actions have been done) but no e-mail come after that.

    I’ve tryed doing actions by simple e-mail with no token actions module : same result, nothing happen.
    I’m using a fresh install of Drupal 6.10 with workflow : 6.x-1.1 http://drupal.org/node/355645 and token 6.x-1.11 http://drupal.org/node/290380

    If anyone could give me a way to follow for finding where is the problem ….
    Thanx in advance.

  5. Conchur

    Fantastic tutorial, thanks very much!

  6. Michael

    Note that for simple workflows it might be good to checkout the Rules Module

  7. William

    A step was left out:

    Assign actions to states

    Ok. Our actions have been created. We need to go back to our workflow section and assign these actions to state transitions.

    Click “Administer” and then “Workflow”

    Add this step >>> In the “Content Type” column, locate “News”. Set its “Workflow” column to “News Publishing”. Click “Save workflow mapping”.

    Click “Actions” next to our “News publishing” workflow.

    Note: Navigate to Administer / Reports / Recent log entries / Filter log messages / Type=workflow / Filter button to see the list of workflows.

    This was the most straightforward tutorial I’ve seen to perform an edit-approve-publish workflow. Thank you!!

  8. Good Article on Drupal Workflow – Kahler Family Happenings

    [...] found this article on Drupal workflow. It’s actually more of a tutorial, but I already typed [...]

  9. jcisio

    Hello,

    Thanks for the good article. I’d like to know whether you plan to use workflow with a terminology permission module. That means an editor can only publish articles in certain terms.

Leave a Reply

Copyright © Michael Adams     powered by WordPress

    RSS Feed HTML 4.01 Valid CSS Valid