https://github.com/timkelty/craft-elementoptions
Craft CMS Plugin: Checkbox Selection + Elements
https://github.com/timkelty/craft-elementoptions
Last synced: about 1 year ago
JSON representation
Craft CMS Plugin: Checkbox Selection + Elements
- Host: GitHub
- URL: https://github.com/timkelty/craft-elementoptions
- Owner: timkelty
- License: mit
- Created: 2016-04-11T11:12:49.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2017-08-14T16:20:52.000Z (almost 9 years ago)
- Last Synced: 2025-03-22T09:04:05.635Z (about 1 year ago)
- Language: PHP
- Homepage:
- Size: 956 KB
- Stars: 35
- Watchers: 3
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# ElementOptions plugin for Craft CMS
ElementOptions fieldtypes function similar to the native [Checkboxes](https://craftcms.com/docs/checkboxes-fields) fieldtypes, with the addition of a selected element to each option.
Each element type is supported with it's own fieldtype: Assets, Users, Entries, and Categories.

## Why
The intital need for this plugin was to create a "layout selection" field. While a [radio buttons](https://craftcms.com/docs/radio-buttons-fields) field would do the trick, we wanted to be able to show a selectable image instead of a checkbox and text.
The most applicable element type is Assets, as it allows you to create a field where users can select from a pre-defined set of Assets.

## Installation
- Via Composer: `composer require timkelty/craft-elementoptions`
- Git: `git clone https://github.com/timkelty/craft-elementoptions.git craft/plugins/elementoptions`
- Download & unzip the into `craft/plugins/elementoptions` directory
ElementOptions works on Craft 2.4.x and Craft 2.5.x.
## Settings

See [Craft Docs for Checkboxes Fields / Settings](https://craftcms.com/docs/checkboxes-fields#settings).
- Limit the number of selectable options
- Select an element for each option, and how that element will be displayed (thumbnails, label, checkbox)
- **Option Label** and **Value** may contain tags that reference the selected entry, such as `{title}` or `{slug}`. This can be useful if you want the label/value to change with element, and vice-versa.
### Templating
See [Craft Docs for Checkboxes Fields / Templating](https://craftcms.com/docs/checkboxes-fields#templating).
- `option.element` is available. It will return an `ElementCriteriaModel`.
```html
- {{ option.element.first().title }}
{% for option in entry.elementOptionsFieldHandle %}
{% endfor %}
```