beebmx/kirby-policy

Kirby 4 的 Blueprint Policies

安装: 52

依赖: 0

建议者: 0

安全: 0

星标: 13

关注者: 2

分支: 0

开放问题: 0

类型:kirby-plugin

1.0.7 2024-08-02 17:45 UTC

This package is auto-updated.

Last update: 2024-09-02 17:58:04 UTC


README

Kirby Policy Logo

Build Status Total Downloads Latest Stable Version License

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.ymlhome.policy.yml(只需使用 home.policy.yml

文件内容

您的 YAML 文件内容需要为每个需要定制的元素添加一个具有用户 rolepolicy 属性

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 许可下发布。

致谢