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?
It’s possible, yes, but I don’t know if this makes sense?
<?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…
4 Likes
Files
and Pages
are classes that extend the general Collection
class. You can create a new collection by doing so:
$pages = $pages->grandChildren();
$collection = new Collection($pages);
$collection->add($pages->files());
1 Like