62 lines
1.6 KiB
Markdown
Raw Normal View History

2015-05-09 15:23:07 +12:00
## Synopsis
Provides a field to easily pick font-awesome icons
2015-05-09 12:31:32 +12:00
## Features
2018-06-24 16:57:15 +07:00
* Easily pick icons to be used anywhere in the backend
* Can filter on icon name
2015-05-09 12:31:32 +12:00
2018-06-24 16:57:15 +07:00
## Requirements
SilverStripe 4+
2015-05-09 12:31:32 +12:00
## Installation
### Composer
Ideally composer will be used to install this module.
2018-06-24 16:57:15 +07:00
```composer require "a2nt/silverstripe-font-awesome:@dev-master"```
2015-05-09 12:31:32 +12:00
## Screen shots
### Font awesome icon view
2015-07-28 10:59:22 +12:00
![Font awesome icon](https://raw.githubusercontent.com/peavers/silverstripe-font-awesome/master/images/screens/font-awesome-icons.png "Icons")
---------------------------------------
### Filter view
2015-07-28 10:59:22 +12:00
![Filter](https://raw.githubusercontent.com/peavers/silverstripe-font-awesome/master/images/screens/font-awesome-filter.png "Filter")
2015-05-09 12:31:32 +12:00
## Usage
A basic working example, and the following to any class you want the field on;
```php
2018-06-24 16:57:15 +07:00
use SilverStripe\FontAwesome\FontAwesomeField;
class Blabla extends ... {
private static $db = array(
'Icon' => 'Varchar(255)',
);
2015-05-09 12:31:32 +12:00
public function getCMSFields()
2015-05-09 12:31:32 +12:00
{
$fields = parent::getCMSFields();
$fields->addFieldsToTab('Root.Main', array(
FontAwesomeField::create("Icon", "Font Awesome icon")
2015-05-09 12:31:32 +12:00
));
return $fields;
}
2018-06-24 16:57:15 +07:00
}
2015-05-09 12:31:32 +12:00
```
Then simple include in the template where you want the icon placed
2015-05-09 12:31:32 +12:00
```html
2018-06-24 17:01:13 +07:00
<i class="$Icon"></i>
2015-05-09 12:31:32 +12:00
```
The controller extension should make sure you've got access to the icons so you don't need to double up the CSS file.
2015-05-09 15:23:07 +12:00
2015-07-28 15:20:45 +12:00
## Want colours instead of icons?
Got you covered, checkout [color-swabs](https://github.com/peavers/silverstripe-color-swabs)!
## Libraries used/modified
2018-06-24 16:57:15 +07:00
* Font Awesome > 5