Upgrade Your Drupal Skills

We trained 1,000+ Drupal Developers over the last decade.

See Advanced Courses NAH, I know Enough

Drupal 8 Scheduler Module

Parent Feed: 

The first step is to download the Drupal 8 Scheduler module and install it. Downloading the module is easy with composer:

composer require drupal/scheduler

In this example, we are only going to cover the Scheduler module. The module comes with a Scheduler Rules Integration module that can be used to integrate Scheduling conditions, actions, and events with the Drupal 8 rules modules.

Drupal Scheduler Module module page

If you navigate to the User permissions page, you can see there are three permissions for the Scheduler module. Typically, you will allow your content editors to schedule content to be published and possible see the list of all content that is scheduled.

Drupal Scheduler Module permissions page

In the Admin menu, navigate to Configuration > Content authoring > Scheduler to get to the Scheduler settings page. Here you can set it up so a content administrator only has to enter the date and the content will be published at a default time. This is useful if you always want content to be published at the same time of day. For now, leave everything at the default.

Drupal Scheduler Module settings page

Click on the Lightweight cron menu item from the Scheduler settings page. If you are only scheduling content to be published occasionally and don’t care if it’s published at exactly the correct time, then you will not need to worry about this admin page. If you need more fine grained control and would like up to the minute publishing, this page provides useful information.

By default, the scheduler actions happen on the default Drupal cron run. Typically you will set up cron to run every hour or possibly once a day, depending on your site needs. The Scheduler module provides a more lightweight cron process available at a callback URL that only runs the scheduler instead of all the default Drupal cron hooks. This makes it more efficient for up to the minute publishing.

Drupal Scheduler Module lightweight cron page

Navigate to Admin > Structure > Content Types. Select Edit on one of the content types you would like to allow scheduling on. In this example, we will use the Article content type.

Content Type Edit

Click on the Scheduler section. Here you can turn on the ability to publish or unpublish this type of content using the Scheduler module. You can specify that creation time should match the publishing time, require that the content be scheduled, and even make sure a new revision is created when the content is published. You can also change how the scheduler options appear on the node edit page (when creating or editing content). For now, just check to turn on Publishing and to change the content creation time to match the scheduled publish time. Then click the Save content type button.

Drupal Scheduler content type options

Now create a new Article and set the Scheduling date and time. Make sure the Article is unpublished and save it. Once that date and time passes and the Drupal cron process runs, this new Article will now be published! Keep in mind, the date/time is based on your site’s timezone settings.

Drupal Scheduler options

You can go to the Content admin page and click the Scheduled menu tab to view all the scheduled content on your site.

As you can see, it’s incredibly easy to set up and start using the Scheduler module. You should now be able to empower your content editors to schedule their content to be

Author: 
Original Post: 

About Drupal Sun

Drupal Sun is an Evolving Web project. It allows you to:

  • Do full-text search on all the articles in Drupal Planet (thanks to Apache Solr)
  • Facet based on tags, author, or feed
  • Flip through articles quickly (with j/k or arrow keys) to find what you're interested in
  • View the entire article text inline, or in the context of the site where it was created

See the blog post at Evolving Web

Evolving Web