marbles/craft-colour-swatches

让客户从预定义的颜色集中进行选择。

安装: 122

依赖项: 0

建议者: 0

安全性: 0

星星: 0

关注者: 1

分支: 23

开放问题: 0

类型:craft-plugin

1.2.8 2020-03-12 07:50 UTC

This package is auto-updated.

Last update: 2024-09-12 18:32:52 UTC


README

Icon

Latest Version Total Downloads

为Craft CMS 3.x提供的颜色样本插件

让客户从预定义的颜色集中进行选择。

这个包之前是 rias/craft-colour-swatches,但自从他放弃了这个包后,他要求我们接管它。请随意使用它!

要求

此插件需要Craft CMS 3.0.0-beta.23或更高版本。

安装

要安装此插件,请按照以下说明操作。

  1. 打开您的终端并转到您的Craft项目

     cd /path/to/project
    
  2. 然后告诉Composer加载此插件

     composer require marbles/craft-colour-swatches
    
  3. 在控制面板中,转到设置→插件,并为颜色样本点击“安装”按钮。

颜色样本概述

不是提供一个完整的颜色选择器,颜色样本允许管理员提供一组颜色供用户选择。

配置颜色样本

创建一个颜色样本字段,并提供标签和十六进制值选项。

Screenshot

通过逗号分隔可以创建多个颜色

Screenshot

使用配置文件

您可以在 config/colour-swatches.php 文件中预先定义可能的颜色或定义不同的调色板。请参阅此存储库中的 配置文件 的示例。

return [

    // Predefined colours
    'colours' => [
        [
            'label' => 'red',
            'color' => '#ff0000',
            'default' => false,
        ],
        [
            'label' => 'green',
            'color' => '#00ff00',
            'default' => false,
        ],
        [
            'label' => 'blue',
            'color' => '#0000ff',
            'default' => false,
        ],
        [
            'label' => 'pink',
            'color' => '#ff00ff',
            'default' => false,
        ]
    ],

    'palettes' => [
        'Red Green' => [
            [
                'label'   => 'red',
                'color'   => '#ff0000',
                'default' => false,
            ],
            [
                'label'   => 'green',
                'color'   => '#00ff00',
                'default' => false,
            ],
        ],
        'Buttons' => [
            [
                'label'   => 'blue-white',
                'color'   => '#0000ff,#ffffff',
                'default' => false,
            ],
            [
                'label'   => 'red-white',
                'color'   => '#ff0000, #ffffff',
                'default' => false,
            ],
        ],
    ],
];

然后,在字段设置中,您可以选择使用预定义的颜色。

Screenshot

使用颜色样本

您可以在模板中访问标签和颜色。默认情况下,标签将显示

{{ fieldName }}
{{ fieldName.label }}
{{ fieldName.labels }} {# Returns an array of all labels #}
{{ fieldName.color }}
{{ fieldName.colours }} {# Returns an array of all colours #}

基于Vigetlabs的出色的Craft 2插件

Marbles提供