Merge pull request #18 from purplespider/publish-date
Update the PublishDate on first Publish
This commit is contained in:
commit
fa517d1b79
|
@ -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->dbObject('PublishDate')->InPast() && !$this->isPublished()) {
|
||||
$this->setCastedField("PublishDate", time());
|
||||
$this->write();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Checks the publish date to see if the blog post has actually been published.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue