A field type for selecting Collection keys - Perch Runway only.
- Download the field type
- Unzip the download
- Place the
collection
folder inperch/addons/fieldtypes
.
- Perch Runway 3.0 or higher
<perch:content id="collections" type="collection" label="Collections">
Limit number collection that can be selected with the max
attribute:
<perch:content id="collections" type="collection" label="Collections" max="1">
If multiple collections are selected, the keys are rendered in the template as a comma-separated string:
Key 1,Key 2,Key 3
An example of how you might use it is to allow an editor to select a single collection to be displayed on a page:
<perch:content id="collections" type="collection" label="Collections" max="1">
$collection_key = perch_content('Collection', true);
if($collection_key) {
perch_collection($collection_key, [
'template' => 'list.html'
]);
}
An example of how you can allow the editor to select multiple collections to be displayed on a page:
<perch:content id="collections" type="collection" label="Collections">
$collection_keys = perch_content('Collections', true);
$collection_keys = explode(',', $collection_keys);
foreach($collection_keys as $collection_key) {
perch_collection($collection_key, [
'template' => 'list.html'
]);
}