# Merge Pages and Files Collection

**URL:** <https://forum.getkirby.com/t/merge-pages-and-files-collection/12833>\
**Category:** Questions\
**Tags:** v3\
**Created:** [February 12, 2019, 1:06pm UTC](https://forum.getkirby.com/t/merge-pages-and-files-collection/12833 "2019-02-12T13:06:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dodo](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/dodo/32/2960_2.png) [@Dodo](https://forum.getkirby.com/u/Dodo)\
**Post date:** [February 12, 2019, 1:06pm UTC](https://forum.getkirby.com/t/merge-pages-and-files-collection/12833/1 "2019-02-12T13:06:54Z")

</div>

Hello everyone,  
I don’t know if its even possible, but i want to generate one big collection of files and subpages for an overviewpage. Basically I’m trying to append `$site->grandChildren()->files()` onto `$pages->grandChildren()`, wich isn’t working because the one is a file object and the other a page object.  
Is there a clever solution for this endeavour or a workaround?

---

<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:** [February 12, 2019, 1:31pm UTC](https://forum.getkirby.com/t/merge-pages-and-files-collection/12833/2 "2019-02-12T13:31:37Z")

</div>

It’s possible, yes, but I don’t know if this makes sense?

```auto
<?php 
$files = new Collection($site->grandChildren()->files());
$pages = new Collection($pages->grandChildren());
$merged = $files->add($pages);
dump($merged);

```

When going through that array, you’d have to find out what is what…

---

<div class="post-metadata">

**Author:** ![pedroborges](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/pedroborges/32/7038_2.png) [@pedroborges](https://forum.getkirby.com/u/pedroborges)\
**Post date:** [February 12, 2019, 1:32pm UTC](https://forum.getkirby.com/t/merge-pages-and-files-collection/12833/3 "2019-02-12T13:32:02Z")

</div>

`Files` and `Pages` are classes that extend the general `Collection` class. You can create a new collection by doing so:

```php
$pages = $pages->grandChildren();

$collection = new Collection($pages);
$collection->add($pages->files());

```
