2017 © Pedro Peláez
 

silverstripe-module gridfield-icon-row-class

SilverStripe module to add (fontawesome) icons and classes to rows in GridFields

image

exadium/gridfield-icon-row-class

SilverStripe module to add (fontawesome) icons and classes to rows in GridFields

  • Wednesday, October 26, 2016
  • by exadium
  • Repository
  • 1 Watchers
  • 7 Stars
  • 86 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 5 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

GridField Icon and Row Class

Adds icons and CSS row classes to DataObjects displayed in GridFields. Enables styling of rows depending on conditions. Example at bottom of README.md uses different colours for rows., (*1)

Screenshot of sample Members GridField with group icons and coloured coded rows, (*2)

Maintainer Contact

Requirements

  • SilverStripe CMS 3.1.x or
  • SilverStripe CMS 3.2.x

Installation

  • composer require "exadium/gridfield-icon-row-class": "dev-master"

Usage

The example below adds icons for Members in the Administrators and Content Authors groups in the Security page of the default SilverStripe CMS installation. It also adds colour (using CSS class) to Member rows depending on their group. Note that the order of the CSS declarations ensures that high priority colours are shown even when multiple groups are assigned., (*3)

mysite/_config/config.yml, (*4)

Member:
  extensions:
    - CustomMember
    - DataObjectIconRowClassExtension

mysite/code/CustomMembers.php, (*5)

<?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;
    }
}

The Versions

26/10 2016

dev-master

9999999-dev https://github.com/marijnkampf/GridField-Icon-Row-Class

SilverStripe module to add (fontawesome) icons and classes to rows in GridFields

  Sources   Download

The Requires

 

css module icon silverstripe icons gridfield set color dataobject colour add rows row