---
title: Types & Paths
order: 40
---

# Types & Paths

Every item Distill finds is given a type and a path. The type tells you what kind of thing it is, the path tells you where it sits within the source. Between them they're how you target the items you want, and how you find your way back to them afterwards.

[TOC]

---

## Types

Types are two segments separated by a colon, the kind of item then its specific type:

| Type                    | Description                                                                                                   |
| ----------------------- | ------------------------------------------------------------------------------------------------------------- |
| `value:[fieldtype]`     | A field value, e.g. `value:text`, `value:assets`                                                              |
| `set:[handle]`          | A Replicator or Bard set                                                                                      |
| `row:[distill-type]`    | A Grid row, see below                                                                                         |
| `node:[type]`           | A Bard node, e.g. `node:paragraph`, `node:heading`                                                            |
| `mark:[type]`           | A Bard mark, e.g. `mark:bold`, `mark:link`                                                                    |
| `entry:[collection]`    | An entry                                                                                                      |
| `term:[taxonomy]`       | A term                                                                                                        |
| `asset:[container]`     | An asset                                                                                                      |
| `user`                  | A user                                                                                                        |
| `raw:[php-type]`        | A raw value, one of `array`, `object` (stdClass only), `string`, `integer`, `float`, `boolean` or `null`      |
| `class:[php-class]`     | Any other object, e.g. `class:Carbon\Carbon`                                                                  |

### Grid Row Types

Grid rows don't have a handle of their own, so Distill adds a **Distill Type** option to the Grid fieldtype. Set that in the field's configuration and its rows will be typed `row:[that-value]`. Rows from a Grid without one are typed `row:unknown`.

### Wildcards

An asterisk matches a single segment and a double asterisk matches any number of segments, so `set:*` matches every set and `**` matches everything. You can match several types at once by separating them with a pipe:

```antlers
{{ distill:builder type="set:image|set:gallery" }}
```

:::note
A single asterisk won't cross the colon, so `type="*"` only matches types with one segment, which is just `user`. Use `**` when you want everything.
:::

---

## Paths

Paths are dot delimited keys from the source to the item, exactly as you'd find them in the stored data. Starting from an entry with a Replicator called `builder`:

```yaml
builder:               # value:replicator @ builder
  -
    type: hero         # set:hero @ builder.0
    heading: Hello     # value:text @ builder.0.heading
    image: hello.jpg   # value:assets @ builder.0.image
                       # asset:images @ builder.0.image.0
```

If you start from the field itself rather than the entry the paths begin at the set index, so `0`, `0.heading` and so on. Grid rows and raw arrays work the same way.

Bard paths follow the structure of the stored ProseMirror document, so text nodes sit under `content`, marks under `marks`, and a set's fields under `attrs.values`:

```yaml
content:                     # value:bard @ content
  -
    type: paragraph          # node:paragraph @ content.0
    content:
      -
        type: text           # node:text @ content.0.content.0
        marks:
          -
            type: bold       # mark:bold @ content.0.content.0.marks.0
  -
    type: set                # set:quote @ content.1
    attrs:
      values:
        text: '...'          # value:text @ content.1.attrs.values.text
```

Paths take the same wildcards as types, a single asterisk for one segment and a double for any number:

```antlers
{{ distill:page path="builder.*.image" }}
{{ distill:page path="**.image" }}
{{ distill:page path="builder.0.*|builder.1.*" }}
```

The `path` parameter doesn't just filter the results, it also stops Distill walking into branches that can't match, which makes it one of the best ways to keep a query fast.

---

## Depth

An item's depth is the number of segments in its path, so `builder.0.heading` is at depth 3. The source itself is at depth 0 and isn't included in the results unless you ask for it with `include_source`.

The `depth`, `min_depth` and `max_depth` parameters filter on that number, and `max_depth` also stops Distill walking any deeper, so it's another good way to limit how much work a query does. Bear in mind that a Bard set's fields are two segments further down than a Replicator set's, because of the `attrs.values` in the path.

---

## Expanding

By default Distill walks into everything it can, which is Replicator, Bard and Grid fields, their sets and rows, relationship fields, and raw arrays and objects. The `expand` parameter restricts that to just the listed types:

```antlers
{{ distill:page type="value:text" expand="value:replicator|set:*" }}
```

That will walk into the page's Replicator fields and their sets, but not into any Bard or Grid fields, and it won't load any relationships. Bard nodes and marks are always walked, they're not affected by `expand`.

Expanding is separate from matching. An item that doesn't match your `type` will still be walked into, because the items you're looking for may be nested inside it.

---

## Relationships

Entries, terms, assets and users fields are expanded to the objects they reference, which are returned as `entry:*`, `term:*`, `asset:*` and `user` items with all of their augmented data. Distill won't walk into them though, only the source of the query has its fields walked.

The same entry or asset can appear more than once in a page, and by default it'll be returned every time it's found. Set `unique="true"` to only return the first occurrence. That only applies to these four types, everything else is unique by definition.
