By james, 9 December, 2022
Advent Calendar door 9 containing Scheduled Publish module

Welcome to day 9 of the Drupal Advent Calendar!

First I must apologise for yesterday. I posted the link to the post of the day on various social media, but I forgot to set the post into a published state before I shared, so nobody could access it.

So today I am sharing a way of preventing this sort of mistake.

Enter the Scheduled Publish module. Instead of manually scheduling a post it allows it to be automatically scheduled at a specified time, cutting out the risk of forgetting to hit “publish”.

This is an extension of the Drupal Workflows module, a core Drupal module, though one that isn’t enabled by default. I won’t cover it in detail here, but it is a powerful way of defining workflows to ensure that content goes through your organisation’s approval process.

Installing the Scheduled Publish module will also enable Workflows. You will then need to enable it for your content type. The simplest way to do this is to go to Configuration → Workflow → Workflows on the Admin Toolbar, edit the default “Editorial” workflow, and under “This workflow applies to” click on Select for content types, and select any content types you would like to schedule.

Next you need to go to the Structure menu and select your content type and choose “Manage fields”. Add a new field and pick “Scheduled publish” as the content type. Give it a name, but leave all other settings at the defaults.

Now, when you add new content of that type, you will see a “Scheduled moderation state change” in the sidebar. You can edit the publication time and date there. You need to specify that you want the new state to be Published.

The Scheduled Publish sidebar

 The scheduling uses your site’s cron scheduler process, so you will need to configure it to run frequently enough to suit your publication schedule. When the cron process does run, it will pick up any content that has passed its scheduled publication time and set it to published.

So now that’s set up, it should ensure that I don’t forget to publish posts. Of course it won’t help me if I forget to post to social media sites.

That’s a brief introduction to the Scheduled Publish module. I hope you find it useful.

Join me tomorrow for another module I find useful.

Advent Calendar with door 9 open revealing Scheduled Publish logo



Restricted HTML

  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.