DEV Community

Vadim Filimonov
Vadim Filimonov

Posted on

Deferred publication in Drupal 8

Install module Scheduler:

composer require drupal/scheduler ; drush en scheduler -y
Enter fullscreen mode Exit fullscreen mode

In the material type settings, check the "Allow this material type to be scheduled for publication.

Image description

When adding/editing material, a delayed publication time field will appear in the sidebar:

We will publish the material in the next century<br>

Specify the time of the future publication, save it. The material will have the status "Unpublished" and will change it to "Published" on the specified date.

The news will be published at the scheduled time only after the cron is started.
Running the standard cron every minute is not required. The Scheduler module provides a light version.

In the settings of the Scheduler module, go to the Lightweight cron tab:

/admin/config/content/scheduler/cron
Enter fullscreen mode Exit fullscreen mode

Image description

Copy the first or second line:

wget -q -O /dev/null "https://tester.ru/scheduler/cron/eeweequeo7ko2auyeengo"
Enter fullscreen mode Exit fullscreen mode

Add this command to the scheduler on your server:

Scheduler in ISP Manager

Scheduled tasks in CPanel

Save, check, use!

Discussion (0)