afbora/kirby-template-hooks

为 Kirby 3 启用页面和文件模板钩子

1.2.2 2023-08-10 08:56 UTC

This package is auto-updated.

Last update: 2024-09-10 11:12:51 UTC


README

Kirby 模板钩子允许您更轻松地管理页面和文件模板的钩子。

安装

使用 composer 安装

composer require afbora/kirby-template-hooks

作为 git 子模块添加

git submodule add https://github.com/afbora/kirby-template-hooks.git site/plugins/kirby-template-hooks

使用方法

页面

使用方法: page.TEMPLATE_NAME.ACTION_NAME:before/after

<?php

return [
    'hooks' => [
        'page.product.update:after' => function ($newPage, $oldPage) {
            // your code goes here
        }
    ]
];

文件

使用方法: file.TEMPLATE_NAME.ACTION_NAME:before/after

<?php

return [
    'hooks' => [
        'file.cover.update:after' => function ($newFile, $oldFile) {
            // your code goes here
        }
    ]
];