# Structured field attr from multiple pages

**URL:** <https://forum.getkirby.com/t/structured-field-attr-from-multiple-pages/20446>\
**Category:** Questions\
**Tags:** v3\
**Created:** [December 18, 2020, 9:42pm UTC](https://forum.getkirby.com/t/structured-field-attr-from-multiple-pages/20446 "2020-12-18T21:42:22Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![kris](https://avatars.discourse-cdn.com/v4/letter/k/82dd89/32.png) [@kris](https://forum.getkirby.com/u/kris)\
**Post date:** [December 18, 2020, 9:42pm UTC](https://forum.getkirby.com/t/structured-field-attr-from-multiple-pages/20446/1 "2020-12-18T21:42:22Z")

</div>

I need to collect, on a single page, one of the values / attributes of a structured field present on different pages (and, in a near future, from different templates). How to proceed ?

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [December 18, 2020, 10:35pm UTC](https://forum.getkirby.com/t/structured-field-attr-from-multiple-pages/20446/3 "2020-12-18T22:35:26Z")

</div>

Could you be a bit more specific? Only one item of each structure, or all values of all items of multiple pages from a specific field in the structure, for example, if you have a structure field with a field email, then all emails entries from all items from multiple pages?

---

<div class="post-metadata">

**Author:** ![kris](https://avatars.discourse-cdn.com/v4/letter/k/82dd89/32.png) [@kris](https://forum.getkirby.com/u/kris)\
**Post date:** [December 19, 2020, 12:07am UTC](https://forum.getkirby.com/t/structured-field-attr-from-multiple-pages/20446/4 "2020-12-19T00:07:01Z")

</div>

Hi, Mark,

thanks for reacting. See below.

---

<div class="post-metadata">

**Author:** ![kris](https://avatars.discourse-cdn.com/v4/letter/k/82dd89/32.png) [@kris](https://forum.getkirby.com/u/kris)\
**Post date:** [December 19, 2020, 12:27am UTC](https://forum.getkirby.com/t/structured-field-attr-from-multiple-pages/20446/5 "2020-12-19T00:27:09Z")

</div>

Hi, Texnixe

sorry if I was not.  
The structure is :

```
----
Externals:
-
    title: 
    icon:
    url:	
----

```

I need to collect, on a single page, the attributes “title” and the “url” of the “Externals” of all the pages of the site which have the youtube “url”.

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [December 19, 2020, 12:34am UTC](https://forum.getkirby.com/t/structured-field-attr-from-multiple-pages/20446/6 "2020-12-19T00:34:38Z")

</div>

I’d probably merge all structure fields into one structure collection, then filter by url. Unlesss the URL is always a youtube url.

Or look through all pages with such a field, the convert field into structure , filter the structure and output the result for each page individually.

---

<div class="post-metadata">

**Author:** ![kris](https://avatars.discourse-cdn.com/v4/letter/k/82dd89/32.png) [@kris](https://forum.getkirby.com/u/kris)\
**Post date:** [December 20, 2020, 1:13pm UTC](https://forum.getkirby.com/t/structured-field-attr-from-multiple-pages/20446/7 "2020-12-20T13:13:00Z")

</div>

Sorry for silence, Texnixe.  
Haven’t found better then :

```
<?php foreach($site->index()->filterby('xxx', 'yyy') as $videos): ?>
<?php if($videos->structuredfield()->tostructure()->isnotempty()): ?>
<?php foreach($videos->structuredfield()->tostructure() as $video): ?>
	<!-- do the stuff -->
```

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [December 20, 2020, 1:33pm UTC](https://forum.getkirby.com/t/structured-field-attr-from-multiple-pages/20446/8 "2020-12-20T13:33:51Z")

</div>

> [@kris](#):
>
> ```auto
> <?php if($videos->structuredfield()->tostructure()->isnotempty()): ?>
> <?php foreach($videos->structuredfield()->tostructure() as $video): ?>
> 
> ```

Coding tip: Always store code you need to repeat in a variable:

```auto
<?php $videoStructure = $videos->structuredfield()->tostructure(); ?>
<?php if($videoStructure->isnotempty()): ?>
<?php foreach($videoStructure as $video): ?>

```

I thought you needed to filter the structure fields themselves, not the parent pages. Your code is fine like that.

---

<div class="post-metadata">

**Author:** ![kris](https://avatars.discourse-cdn.com/v4/letter/k/82dd89/32.png) [@kris](https://forum.getkirby.com/u/kris)\
**Post date:** [December 20, 2020, 1:58pm UTC](https://forum.getkirby.com/t/structured-field-attr-from-multiple-pages/20446/9 "2020-12-20T13:58:51Z")

</div>

noted! 🧐
