mirror of
https://github.com/silverstripe/silverstripe-blog
synced 2024-10-22 11:05:58 +02:00
Update the PublishDate on first Publish
If the PublishDate hasn't been set to the future.
This commit is contained in:
parent
17762568cf
commit
65301b91dc
@ -106,6 +106,18 @@ class BlogPost extends Page {
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Update the PublishDate to now, if being published for the first time, and the date hasn't been set to the future.
|
||||
**/
|
||||
public function onBeforePublish() {
|
||||
if ($this->owner->obj('PublishDate')->InPast() && !$this->owner->isPublished()) {
|
||||
$this->owner->setCastedField("PublishDate", time());
|
||||
$this->owner->write();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Checks the publish date to see if the blog post has actually been published.
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user