# Pass additional page content while merging structure fields

**URL:** <https://forum.getkirby.com/t/pass-additional-page-content-while-merging-structure-fields/13179>\
**Category:** Questions\
**Tags:** v3\
**Created:** [March 4, 2019, 11:02pm UTC](https://forum.getkirby.com/t/pass-additional-page-content-while-merging-structure-fields/13179 "2019-03-04T23:02:10Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![pandorrrrrra](https://avatars.discourse-cdn.com/v4/letter/p/e480ec/32.png) [@pandorrrrrra](https://forum.getkirby.com/u/pandorrrrrra)\
**Post date:** [March 4, 2019, 11:02pm UTC](https://forum.getkirby.com/t/pass-additional-page-content-while-merging-structure-fields/13179/1 "2019-03-04T23:02:10Z")

</div>

I’m merging structure fields (events) from different pages to show an overview of all events on a page, sorted by date. Each event has an image, which is saved outside the structure field, but in the page.  
But now I can’t find a way to display the event with the corresponding image while looping through the new collection. How can I pass the image while the merging is happening, so I can keep the relation between both?

I’m using this as a plugin for the merging:

```
<?php
use Kirby\Cms\Structure;

function createNewStructure($pages, $field)
{
  $structure = new Structure();

  foreach ($pages as $p) {
    $structure->add($p->$field()->toStructure());
  }

  return $structure;
}

```

And get the events like this:

```
<?php $pageCollection = $someCollection; ?>
<?php $mergedEvents = createNewStructure($pageCollection, 'events'); ?>
<?php foreach ($mergedEvents->sortBy('dateStart', 'asc') as $event): ?>
  <?= $event->name() ?>
  <?php $thumb = // How to get the image from the related page in $pageCollection? ?>
  <img src="<?= $thumb->url() ?>">
<?php endforeach ?>

```

Thanks for any tip !

---

<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:** [March 4, 2019, 11:15pm UTC](https://forum.getkirby.com/t/pass-additional-page-content-while-merging-structure-fields/13179/2 "2019-03-04T23:15:44Z")

</div>

How are the images assigned to each item? Is there a field in the structure field that contains the image name?

You can access the page that is associated with each structure object using the `parent()` method, in your case:

```auto
$parent = $event->parent();
dump($parent);

```

should give you the page object.

---

<div class="post-metadata">

**Author:** ![pandorrrrrra](https://avatars.discourse-cdn.com/v4/letter/p/e480ec/32.png) [@pandorrrrrra](https://forum.getkirby.com/u/pandorrrrrra)\
**Post date:** [March 4, 2019, 11:32pm UTC](https://forum.getkirby.com/t/pass-additional-page-content-while-merging-structure-fields/13179/3 "2019-03-04T23:32:06Z")

</div>

Perfect, that works !  
The image is assigned outside the structure field, so I couldn’t figure out how to access it.  
Thanks a lot
