Delayed publication

Set a specific date/time for an entry to switch from unpublished to published, assisted by a cron job.

Should this be an addon or is it more close to core?

What would be the best approach to add this to Cockpit?

I would do this using plain PHP in you webpage / frontend. No need for using crons or making things more complex then they need to be.

Just add a (datepicker-)field for the desired publishing-date to your collection.

Then when processing the entries that have been fetched from the cockpit-api/collection, create a PHP DateTime Object (http://php.net/manual/de/class.datetime.php) from the (datepicker-)field that holds the publishing-date.

Next create one more DateTime-object with the very current datetime (the obj will automatically contain the current time when you just do new DateTime()) and compare them to each other using the date-/datetime-diff functions like so: https://stackoverflow.com/questions/19031235/php-check-if-date-is-past-to-a-certain-date-given-in-a-certain-format/19031322 .

If the date of the entry is less recent then the current datetime, it may be shown because the publishing date was exeeded

That could work, but it doesn’t flip the Published flag.

a field that defines a date when the post should be published renders a dedicated “published” boolean-field completely redundant

but if you want to have a dedicated boolean field and want it to be auto-set to true as the publishing-data of an entry is exeeded, you can use webhooks (with the event “collections.find.before” (see https://github.com/agentejo/cockpit/issues/661 for all events that can be hooked)) in order to update a entry which’s publishing time is in the past

I can see some scenarios where that make sense, think it can be implemented as an addon without too much effort:

  1. Addon provides a new field type (publishing availability) with two values (from and to)
  2. Addon implements the collections.find.after hook, and if the field type is present and the required conditions are not met (from/to date from field value matches the current date) will filter out the entry

Using above approach you can define a period range where the contents will be returned or not.

This makes a lot of sense. Thanks!

Since this is an interesting use case I created a new addon that provides the functionality that described above:

Hope that helps.

That’s awesome! Thanks!