https://github.com/jaedb/iconfield
SilverStripe icon selection field
https://github.com/jaedb/iconfield
silverstripe silverstripe-4 silverstripe-module
Last synced: 4 months ago
JSON representation
SilverStripe icon selection field
- Host: GitHub
- URL: https://github.com/jaedb/iconfield
- Owner: jaedb
- Created: 2018-02-21T21:56:33.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2024-04-13T01:48:30.000Z (over 2 years ago)
- Last Synced: 2025-04-11T19:08:25.506Z (over 1 year ago)
- Topics: silverstripe, silverstripe-4, silverstripe-module
- Language: PHP
- Size: 27.3 KB
- Stars: 2
- Watchers: 1
- Forks: 8
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Description
Simplifies the use of icons in a way content authors can set icons without interfering with the asset library. Instead, the web developer provides the icon set which the end-user can use but not manipulate.

# Requirements
* SilverStripe 4
# Usage
* Import the required classes:
```
use Jaedb\IconField\Icon;
use Jaedb\IconField\IconField;
```
* Set your `$db` field to type `Icon` (eg `'PageIcon' => Icon::class`)
* `IconField::create($name, $title, $iconFolder)`
* `$name` is the database field as defined in your class
* `$title` is the label for this field
* `$iconFolder` (optional) defines the directory where your icons can be found. Defaults to `/site/icons`.
* To change your default icon directory, see `_config/config.yml`.
* Use your icon in templates as you would any other property (eg `$PageIcon`). If your icon is an SVG, the SVG image data will be injected into the template. To prevent this, you can call `$PageIcon.IMG` instead to enforce use of `
` tags.