xddesigners / iconselectfield
添加一个可配置的图标选择字段
dev-main
2023-10-06 07:53 UTC
Requires
- heyday/silverstripe-colorpalette: ^2.0
- silverstripe/framework: ^4 || ^5
This package is auto-updated.
Last update: 2024-09-06 09:48:11 UTC
README
向 Silverstripe CMS 添加图标选择字段。
安装
composer require xddesigners/iconselectfield
使用
将图标字段添加到您的数据库中。此字段将自动生成 IconSelectField
。
class YourClass extends DataObject { private static $db = [ 'Icon' => 'Icon' ]; public function getCMSFields() { $fields = parent::getCMSFields(); $fields->addFieldsToTab('Root.Main', [ // this field is automaticly scaffolded IconSelectField::create('Icon', 'Icon') ]); $fields; } }
在您的模板中,现在可以访问 Icon 属性,这将替换为所选图标。
$Icon
您可以通过 yml 配置文件配置您想使用的图标。
--- Name: vivabasicIcons --- XD\IconSelectField\Forms\IconSelectField: fonts_include: # add your own link to a font awesome version your using - '<link rel="stylesheet" href="https://pro.fontawesome.com/releases/v5.12.1/css/all.css" crossorigin="anonymous">' icons: system: arrow-right: 'fas fa-arrow-right' arrow-left: 'fas fa-arrow-left' custom-icon: '<svg />' # you can also configure custom svg icons