Add a created and updated date field blueprint and a hook that automatically updates the updated date when saving a page.
This commit is contained in:
@@ -24,6 +24,7 @@ Kirby::plugin(
|
||||
"blueprints" => [
|
||||
"fields/link-locations" => __DIR__ . "/blueprints/fields/link-locations.yml",
|
||||
"fields/link-location" => __DIR__ . "/blueprints/fields/link-location.yml",
|
||||
"fields/dates" => __DIR__ . "/blueprints/fields/dates.yml",
|
||||
],
|
||||
"snippets" => [
|
||||
"navbar/primary" => __DIR__ . "/snippets/navbar/primary.php",
|
||||
@@ -114,6 +115,14 @@ Kirby::plugin(
|
||||
|
||||
return $links;
|
||||
},
|
||||
"page.update:after" => function ($newPage, $oldPage) {
|
||||
if ($newPage->updated()->exists()) {
|
||||
# Set the last updated time to now.
|
||||
$newPage->update([
|
||||
"updated" => date("Y-m-d H:i"),
|
||||
]);
|
||||
}
|
||||
},
|
||||
],
|
||||
"siteMethods" => [
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user