Collections Fieldtype
Allows you to choose one or more collections.
Usage
This fieldtype is used to view and select from a list of Collections.
fields:
my_collections_field:
type: collections
Data Structure
The Collections fieldtype is a Relationship fieldtype, and will save the collections as their handles (the folder name).
listings:
- blog
- things
Templating
You're more than likely using this field as a way to dynamically display a collection.
Since the collection tag accepts a pipe-delimited list of collection names, you can join them together like this:
<ul>
{{ collection from="{listings|piped}" }}
<li>{{ title }}</li>
{{ /collection }}
</ul>
You can pass the values from the collections fieldtype to the collection tag like so:
<ul>
<statamic:collection
:from="$listings ?? []"
>
<li>{{ $title }}</li>
</statamic:collection>
</ul>
<ul>
<li>A blog entry</li>
<li>A thing entry</li>
<li>etc</li>
</ul>
Options
max_items
integer
The maximum number of items that may be selected. Setting this to 1
will change the UI to a dropdown.
Docs Feedback
Submit improvements, related content, or suggestions through Github.
Betterify this page