codemonauts/craft-customizable-radio-buttons-field

Craft CMS 插件,用于添加可定制的单选按钮字段,支持 CSS 类、图标、图片和文本。

2.0.0 2022-04-27 18:22 UTC

This package is auto-updated.

Last update: 2024-08-30 01:20:15 UTC


README

Icon

一个字段类型,可以向 Craft CMS 添加可定制的单选按钮。

背景

图片胜过千言万语。使用这个插件,您可以添加单选按钮作为字段,它们可以是图片、图标、CSS 类、文本或它们的组合。

要求

  • Craft CMS >= 4.0.0

安装

打开您的终端并进入您的 Craft 项目

cd /path/to/project
composer require codemonauts/craft-customizable-radio-buttons-field

在控制面板中,转到设置 → 插件,并点击 自定义单选按钮字段 的“安装”按钮。

配置

config.php 复制到您的配置文件夹中,命名为 buttons.php。然后添加按钮组,如下所示

<?php

return [
  'cssFile' => '@config/path/to/my.css', // optional path to a local CSS file. This will be automatically published.
  'cssUrl' => 'https://example.com/awesome.css' // Optional URL to an external CSS.
  'buttonGroups' => [
    'myhandle' => [
      'name' => 'My awesome buttons', // The name in the field's configuration dialog.
      'buttons' => [
        'handle-button-1' => [
          'image' => '@buttonsAssets/myimage.jpg', // Optional Image, overwrites 'label'.
          'title' => 'My button 1', // Title and Alt Attributes.
          'value' => 'myvalue', // The value to store (string)
          'class' => 'myclass', // Optional class(es) to add to the button.
          'label' => 'abc', // The button's text, will be overwritten when an image is set.
        ],
        'handle-button-2' => [
          // ...
        ],
        // ...
      ],
      // ...
    ],
  ],
];

您可以拥有多个按钮组。它们都共享相同的 CSS 文件或 CSS URL,您可以进行配置。请参阅 示例

codemonauts 爱心奉献