Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds a
{{ dictionary }}
tag to Antlers, allowing you to use dictionaries outside the field type.Usage:
{{ dictionary:countries }}{{ label }} {{ value }}{{ /dictionary:countries }}
or
{{ dictionary handle="countries" }}{{ label }} {{ value }}{{ /dictionary}}
It also gets any ‘extra’ data:
{{ dictionary handle="countries" }}{{ emoji }} {{ value }}{{ /dictionary}}
Searching:
{{ dictionary:countries search="Aus" }}{{ label }} {{ value }}{{ /dictionary:countries }}
Passing config:
Any params passed that arent handle or search will be passed as config... eg
{{ dictionary:countries emojis="false" }}{{ label }} {{ value }}{{ /dictionary:countries }}
conditions, pagination, chunking and limiting:
It supports conditions, pagination, chunking and limiting eg
{{ dictionary:countries iso2:is="AUS" paginate="4" }}{{ label }} {{ value }}{{ /dictionary:countries }}
query scopes
You can also use query scopes:
{{ dictionary:countries query_scope="my_scope" }}{{ label }} {{ value }}{{ /dictionary:countries }}
Files:
Where this gets really powerful is pulling in arbitrary files and being able to filter, paginate and output them:
{{ dictionary:file filename="products.json" label="Name" value="Code" paginate="4" }}
Note:
Under the hood its using an Item query builder to allow filtering, ordering etc.
Closes statamic/ideas#1214.