🚧 Work In Progress: Some things may change/break. Feedback welcome.
This Statamic addon allows you to filter, fetch or index the individual values, sets and relations within your entries, from both root and deeply nested fields. It's useful for things like:
You can search for this addon in the Tools > Addons
section of the Statamic control panel and click install, or run the following command from your project root:
composer require jacksleight/statamic-distill
{{ distill:page type="asset:*" is_image:is="true" unique="true" }}
{{ url }}
{{ /distill:page }}
{{ { distill:bard from="builder" } | bard_text }}
{{ distill:parts_list depth="1" paginate="10" :category:is="get:category" :sort="get:sort" }}
{{ items }}
{{ name }} {{ price }}
{{ /items }}
{{ paginate }}
<a href="https://github.com/jacksleight/statamic-distill/blob/main/{{ prev_page }}">←</a>
<a href="https://github.com/jacksleight/statamic-distill/blob/main/{{ next_page }}">→</a>
{{ /paginate }}
{{ /distill:parts_list }}
// config/statamic/search.php
'searchables' => [
'distill:collection:pages:sections',
],
'fields' => ['heading'],
// app/Stills/Sections.php
namespace App\Stills;
use JackSleight\StatamicDistill\Stills\Still;
class Sections extends Still
{
public function apply($query, $values)
{
$query->path('builder.*')->type('set:section');
}
}
{{# resources/views/search.antlers.html #}}
{{ search:results }}
{{ if result_type === 'distill:set:section' }}
<a href="https://github.com/jacksleight/statamic-distill/blob/main/{{ info:source:url }}#{{ id }}">
{{ title }}
</a>
{{ else }}
...
{{ /if }}
{{ /search:results }}
Distill recursively walks through the value you provide looking for items that match your criteria. It can find individual paragraphs and field values through to entire sets and references to other content.
For optimal performance you should use the from
, path
, expand
, limit
and max_depth
parameters to restrict where it goes based on what you're looking for. These options don't just filter the final result, they tell Distill where to look and when to stop.
Distill can find references to other entries, terms, assets and users, but it will not walk into those objects. Additionally Distill will only walk raw values if you provide one, it will not walk into a field's raw value.
The {{ distill:* }}
tag accepts the following parameters:
value:[fieldtype]
- A field valueset:[handle]
- A Replicator or Bard setrow:[distill-type]
- A Grid row (type can be defined in the field config)node:[type]
- A Bard nodemark:[type]
- A Bard markentry:[collection]
- An entryterm:[taxonomy]
- A termasset:[container]
- An assetuser
- A userraw:[php-type]
- A raw valuemax_depth
and min_depth
.entry
term
asset
user
set:[handle]
row:[distill-type]
value:replicator
value:bard
value:grid
value:entries
value:terms
value:assets
value:users
raw:array
raw:object
Each item returned includes an info
object that contains the following values:
This addon is completely free to use. However fixing bugs, adding features and helping users takes time and effort. If you find this addon useful and would like to support its development any contribution would be greatly appreciated. Thanks! 🙂