Tutorial 3: Schedule the publishing of content

Last modified: November 19, 2007 - 19:51

Workflow-ng comes with a few extension modules, which provide some further optional functionality. One of those is the Configurable Content Links module, in short cclinks. We will use it to generate a scheduled workflow-ng event, for which we configure an action that publishes the content.

Configurable Content Links

First off more about this module:
This module provides configurable content links, that generate events when they are pressed. Optionally one can activate scheduling for a link, so that the user can set the date when the event will be invoked. This may be used for scheduled execution of arbitrary actions, e.g. one can use it to schedule the publishing of content.
Each link can be configured to toggle between to different link labels. Thanks to the State Machine API the current link state is exposed to Views too. Access permissions can be controlled independently for each link.

Note:
To make date selecting more user friendly, install the JS Calendar of the Javascript Tools modules package: http://drupal.org/node/57285

So install it and also install the js calendar module.

Creating a link for scheduling..

So now you can go ahead configuring the link, with which we will generate the scheduled event. Go to the modules admin page (admin/build/cclinks) and press "Add a content link". Choose the label "Scheduled Publishing" and select the content type, which should be published scheduled, e.g. "story". Then set the link labels, e.g. to "schedule publishing" and "publishing scheduled" - so the link will toggle to publishing scheduled as soon as the publishing has been scheduled.. :) Don't forget to activate "Schedule event occurance" and customize the "Schedule Date Form", e.g. set the page title "Scheduled Publishing".
After clicking "Submit" you are back in the admin interface, where you can see now the newly create link.

Adjust access control

Proceed adjust the access control. Go to drupal's access control page (admin/user/access) and grant some roles access to your newly created link.

Now you can test it, create a story (or whatever content type you have chosen). When you view the story there will be the configured link - on click you can set the publishing date.

Configure the publishing action

So far there is only the work, but there won't happen anything on event schedule. So go to workflow-ng's admin page (admin/build/workflow-ng) and add a new configuration. Call it "Publish content" and choose the cclinks event "Scheduled Publishing". Add a new action, call it "publish", check "Published" and submit.

Now we have everything configured. To test create an unpublished story and schedule it's publishing with "now". The story should be published immediately.

Of course you could also add another configuration or action to the event, e.g. it might make sense to log the scheduled publishing. To do so, just add an "Log to watchdog" action.

 
 

Drupal is a registered trademark of Dries Buytaert.