tobimori / kirby-icon-field
为 Kirby CMS 设计的简单图标字段插件
2.0.2
2024-04-27 21:51 UTC
Requires
- php: >=8.2.0
- getkirby/composer-installer: ^1.2
Requires (Dev)
- getkirby/cms: ^4.0.1
This package is auto-updated.
Last update: 2024-09-27 22:43:17 UTC
README
Kirby Icon Field
为 Kirby 4+ 提供的简单图标字段 - 将你的图标包放入文件夹,将字段添加到你的蓝图,即可使用。
如果你使用的是 Kirby 3.9+,请尝试使用 v1.0.3。
安装
推荐:Composer
composer require tobimori/kirby-icon-field
手动安装
下载并将此存储库复制到 /site/plugins/kirby-icon-field
,或将此存储库作为 Git 子模块应用。
使用
此插件依赖于将你的 SVG 图标作为单独的文件存储在文件夹中以在面板中显示 - 当然,你可以在模板中对字段的值做任何处理。
图标将始终以单色白色或黑色显示。
将字段添加到蓝图
fields: icon: label: Icon type: icon folder: assets/icons # path to your icon folder, relative to the `index` kirby root max: 1 # max number of icons to select - 1 will look like a 'select field', none or more like a 'multiselect' field sprite: svg-sprite.svg # optional, path to your svg sprite relative to folder option, if you want to use a sprite instead of individual files # [more settings...] - same as multi-select field, e.g. disabling search, limiting icons, etc.
注意
如果你使用的是精灵图,请确保文件可在用户指定的路径下访问。插件不会复制或移动文件,它只会引用它。与单个文件模式不同,#id
引用将存储不带 .svg
扩展名。
在模板中使用字段值
<?= svg('/assets/icons/' . $page->icon()) ?>
选项
选项允许你微调插件的行为。你可以在你的 config.php
文件中设置它们
return [ 'tobimori.icon-field' => [ 'cache' => true, 'folder' => 'assets/icons' ], ];
支持
注意
此插件免费提供,并根据宽松的 MIT 许可证发布。如果你在商业项目中使用它,请考虑在 GitHub 上赞助我 以支持进一步开发和持续维护 Kirby Icon Field。
许可证
MIT 许可证 版权所有 © 2023-2024 Tobias Möritz
预览图像中的图标是 Chunk Icons 的部分,由 Noah Jacobus 提供。 <3