exadium / gridfield-icon-row-class
此软件包的最新版本(dev-master)没有提供许可证信息。
为GridFields中的行添加(fontawesome)图标和CSS类别的SilverStripe模块
dev-master
2016-10-26 16:54 UTC
Requires
- silverstripe/cms: ~3.1
- silverstripe/framework: ~3.1
This package is not auto-updated.
Last update: 2024-09-26 00:29:50 UTC
README
向在GridFields中显示的数据对象添加图标和CSS行类。根据条件启用行的样式。README.md文件底部的示例使用不同的颜色为行着色。
维护者联系方式
- Marijn Kampf (Exadium)
要求
- SilverStripe CMS 3.1.x 或
- SilverStripe CMS 3.2.x
安装
- composer require "exadium/gridfield-icon-row-class": "dev-master"
用法
以下示例在默认的SilverStripe CMS安装的“安全”页面中为“管理员”和“内容作者”组中的成员添加图标。它还根据组成员添加颜色(使用CSS类)。请注意,CSS声明的顺序确保即使分配了多个组,高优先级的颜色也会显示。
mysite/_config/config.yml
Member:
extensions:
- CustomMember
- DataObjectIconRowClassExtension
mysite/code/CustomMembers.php
<?php
class CustomMember extends DataExtension {
function __construct() {
$self = $this;
parent::__construct();
Requirements::customCSS(<<<CSS
table.ss-gridfield-table tr.blue.odd { background-color: #D9EDF7; }
table.ss-gridfield-table tr.blue.even { background-color: #BCE8F1; }
table.ss-gridfield-table tr.amber.odd { background-color: #FAEBCC; }
table.ss-gridfield-table tr.amber.even { background-color: #FCF8E3; }
table.ss-gridfield-table tr.red.odd { background-color: #F2DEDE; }
table.ss-gridfield-table tr.red.even { background-color: #EBCCD1; }
.menu-icon { padding: 0 0.25rem; }
.col-GridFieldIconRowClass { text-align: center; }
CSS
);
}
public function GridFieldIconRowClassesUpdated() {
if ($this->owner->inGroup("administrators")) $this->owner->addGridFieldIconRowClass("user-plus", "Administrator", "red");
if ($this->owner->inGroup("content-authors")) $this->owner->addGridFieldIconRowClass("pencil-square-o", "Content author", "amber");
return $this->owner->GridFieldIconRowClasses;
}
}