Merge Collection of Pages

I’d like to merge two or more collections of Kirby page objects. In Kirby 1 there was something like Pages::merge($collection1, $collection2), but this doesn’t seem to work in Kirby 2.

Are there any alternative? Thanks in advance to anybody who might have an idea!

Till

$pages->add($collection);

//Merge two collections

<?php 
  $exhibitions = $pages->find('exhibitions')->visible()->children()->filterB('now', 'noo');
  $news  = $pages->findBy('news')->visible()->children();
  $homeflux = new Pages(array($exhibitions, $news));
?>

//Appending stuff to a collection:

<?php 
  $homeflux = new Pages();
  $homeflux->add($pages->find('exhibitions')->visible()->children()->filterBy('now', 'noo'));
  $homeflux->add( $pages->findBy('news')->visible()->children());
// etc...
?>
6 Likes

Thank you, @walkerbox and @texnixe! That did the trick!