Kirby template hooks allow you to manage hooks for page and file templates more easily.
composer require afbora/kirby-template-hooks
git submodule add https://github.com/afbora/kirby-template-hooks.git site/plugins/kirby-template-hooks
Usage: page.TEMPLATE_NAME.ACTION_NAME:before/after
<?php
return [
'hooks' => [
'page.product.update:after' => function ($newPage, $oldPage) {
// your code goes here
}
]
];
Usage: file.TEMPLATE_NAME.ACTION_NAME:before/after
<?php
return [
'hooks' => [
'file.cover.update:after' => function ($newFile, $oldFile) {
// your code goes here
}
]
];