# Page.extra array selector

**URL:** <https://zola.discourse.group/t/page-extra-array-selector/2064>\
**Category:** Uncategorized\
**Created:** [February 24, 2024, 7:22am UTC](https://zola.discourse.group/t/page-extra-array-selector/2064 "2024-02-24T07:22:26Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![adrianboston](https://yyz2.discourse-cdn.com/free1/user_avatar/zola.discourse.group/adrianboston/32/907_2.png) [@adrianboston](https://zola.discourse.group/u/adrianboston)\
**Post date:** [February 24, 2024, 7:22am UTC](https://zola.discourse.group/t/page-extra-array-selector/2064/1 "2024-02-24T07:22:26Z")

</div>

given front matter with an array as such

```auto
+++
[extra]
features = [
        {name="Weight", value="1.12 kg"},
        {name="Dimensions", value="4 x 8 m"},
]

```

is it possible to select one matching a selector along the lines of

`page.extra.features[name='Weight']`

---

<div class="post-metadata">

**Author:** ![AndreaTitolo](https://avatars.discourse-cdn.com/v4/letter/a/977dab/32.png) [@AndreaTitolo](https://zola.discourse.group/u/AndreaTitolo)\
**Post date:** [February 24, 2024, 8:32am UTC](https://zola.discourse.group/t/page-extra-array-selector/2064/2 "2024-02-24T08:32:23Z")

</div>

Possibly a bit verbose but maybe something like this? If I understood correctly.

```auto
{% for feature in page.extra.features %}
    {% if feature.name is matching("Weight") %}
        {{ feature.name }}
    {% endif %}
{% endfor %}

```

Corresponding [tera docs](https://keats.github.io/tera/docs/#matching).

---

<div class="post-metadata">

**Author:** ![adrianboston](https://yyz2.discourse-cdn.com/free1/user_avatar/zola.discourse.group/adrianboston/32/907_2.png) [@adrianboston](https://zola.discourse.group/u/adrianboston)\
**Post date:** [February 24, 2024, 7:34pm UTC](https://zola.discourse.group/t/page-extra-array-selector/2064/3 "2024-02-24T19:34:28Z")

</div>

Yes, i’m currently doing that. It’s nasty.  
I was hoping some short cut existed for accessing objects.

its possible to access a value using the key

{`{ page.extra['title'] }}`

and also possible to access an object (not within an array) given

```auto
+++
[extra]
weight = {unit="kg", value=1.2}

```

both forms access the object in the template

```auto
{{ page.extra.weight.value }} {{ page.extra.weight.unit }}
{{ page.extra.weight['value'] }} {{ page.extra.weight['unit'] }}

```

but not for accessing an object WITHIN an array.

```auto
+++
[extra]
features = [
        {name="Weight", value="1.12 kg"},
        {name="Dimensions", value="4 x 8 m"},
]

```

ill try the some tera ‘built-ins’

---

<div class="post-metadata">

**Author:** ![adrianboston](https://yyz2.discourse-cdn.com/free1/user_avatar/zola.discourse.group/adrianboston/32/907_2.png) [@adrianboston](https://zola.discourse.group/u/adrianboston)\
**Post date:** [February 24, 2024, 7:48pm UTC](https://zola.discourse.group/t/page-extra-array-selector/2064/4 "2024-02-24T19:48:21Z")

</div>

The tera [filter](https://keats.github.io/tera/docs/#filter) looks promising

```auto
page.extra.feature | filter(attribute='name', value="Weight")}}

```

Looks like it returns an array of object. Now to access the first element in the array.

```auto
{% set x = page.extra.feature | filter(attribute='name', value="Weight") | first %}
{{x}}

```

Would like to access that in one line but this is a good start
