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:
2026-04-17 04:14:28 +10:00
parent e8c5e32768
commit aeaed44fcd
2 changed files with 28 additions and 0 deletions

View File

@@ -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" => [
/**