Although the ability to publish and unpublish exists in the Scheduler module, it works with any content entity.
This module allows you to schedule the publishing and unpublishing of any content entity type (node, term, or even path_alias (theoretically), plus any custom entity you might create - as long as it has a "status" property and the other fields listed below).
In addition it does this using the generic Event Scheduler module that uses Symfony events rather than hooks.
How to use
Assuming you have this module installed and enabled all you have to do is add either or both of the following fields to the entity or bundle:
* `field_scheduled_start`
* `field_scheduled_end`
These must be date fields storing in the `Y-m-d\TH:i:s` format. They can be just for the "date" part, in which case it will be assumed to be the start of the day for the publish, and the end of the day for the unpublish.
The timezone used will be the one belonging to the creator of the entity.
If the publish date/time is already past, the entity will be published immediately. Similarly for the unpublish date/time.
Events
You don't need to do any coding for this to work but for developers there are two events issued once the action has been performed:
EntityPublishedEventwhen an entity has been successfully published.EntityUnpublishedEventwhen an entity has been successfully unpublished.
If you want to carry out other actions you will normally intercept those two in an event subscriber. Those two events are both delayed events and will be launched after the rest of the page has been built and sent to the browser.
If an entity is deleted while events are pending, those events are automatically removed.
And that's all there is to it.
Important note
No module of this type can guarantee publishing at an exact time because scheduled events depend on when "cron" is run. The more frequently it's run, the closer to the correct time the publish/unpublish will be.
Project information
- Project categories: Developer tools, Performance
- Ecosystem: Event Scheduler
6 sites report using this module
- Created by adaddinsane on , updated
Stable releases for this project are covered by the security advisory policy.
There are currently no supported stable releases.
