statamic / ideas

💡Discussions on ideas and feature requests for Statamic
https://statamic.dev
32 stars 1 forks source link

Allow "published" field to be defined as a computed property #1223

Open dadaxr opened 2 months ago

dadaxr commented 2 months ago

Would be great to be able to define the "published state" (true or false) as a computed property to define our own logic...

For instance, I would allow us to control easily a "publish period (with both a start and end date), or for example to force the unpublish after a certain amount of time... (for example to auto clear some expired job entries or something like that)

I tried to define a computed prop with the "handle" value, but the native "published" field takes over... so the computed value is overrode.

From a performance point of view, it would be important to mention in the doc this computed property would be queried by default when using collection antlers tag so it's important to keep fast and simple "computed code".

What do you think ?

For the moment, the only way to do that is by creating a CustomEntry class overriding the default status() and private() methods of the Statamic\Entries\Entry class

duncanmcclean commented 2 months ago

Related to #743.