beebmx / kirby-policy
Kirby 4 的 Blueprint Policies
1.0.7
2024-08-02 17:45 UTC
Requires
- php: ^8.2
- getkirby/composer-installer: ^1.1
Requires (Dev)
- getkirby/cms: ^4.2
- laravel/pint: ^1.10
- pestphp/pest: ^2.0
- spatie/ray: ^1.40
README
Kirby Policy
一种简单的方式,用于在Kirby面板中根据不同的用户角色显示不同的内容。
概述
安装
下载
下载并将此仓库复制到 /site/plugins/kirby-policy。
Composer
composer require beebmx/kirby-policy
使用方法
您可以像往常一样创建您的 YAML 文件;您只需要遵循文件结构和文件内容。
文件结构
在您的 blueprints 目录中,您可以放置后缀为 policy 的 YAML 文件
blueprints ├── pages │ ├── default.yml │ ├── home.policy.yml │ ├── simple.policy.yml │ ├── multiple.policy.yml │ ├── content.yml │ ├── blog.yml │ └── post.policy.yml ├── users │ ├── admin.yml │ └── editor.yml └── site.yml
注意
您不能有一个没有前缀的文件,以避免忽略策略文件,例如 home.yml 和 home.policy.yml(只需使用 home.policy.yml)
文件内容
您的 YAML 文件内容需要为每个需要定制的元素添加一个具有用户 role 的 policy 属性
title: Page tabs: # Only an admin will see the admin tab admin: label: Admin policy: admin columns: main: type: fields fields: item: label: Item type: text content: label: Content icon: page columns: main: width: 2/3 sections: content: type: fields fields: text: label: Text type: text # Only an admin will see the admin field admin: label: Admin type: text policy: - admin # Only an editor will see the editor field editor: label: Editor type: text policy: - editor # An admin and editor will see the mixed field mixed: label: Mixed type: text policy: - admin - editor sidebar: sticky: true width: 1/3 sections: pages: type: pages template: default files: type: files
注意
属性 policy 可以是字符串或 roles 的数组
选项
许可证
在 MIT 许可下发布。
致谢
- Fernando Gutierrez @beebmx
- jonatanjonas
logo - 所有贡献者