Can't find home when using add to collection

Is this a bug or am I doing something wrong?

Warning: scandir(C:\wamp\www\kirby\content\pages\home,C:\wamp\www\kirby\content\pages\home): The system cannot find the file specified. (code: 2) in C:\wamp\www\kirby\kirby\core\page.php on line 295

$collection = $site->find('pages')->children()->not('revisions');

I have a home/home.txt file in my content folder. It’s always been there.


$home = $site->find('home');
echo $home->title(); // Work, prints "Home" on the screen

$collection = $site->find('pages')->children()->not('revisions');
$collection->add($home); // Doesn't work!

The $children->add() method only works with other children of the same parent.

You can use this:

$collection->append('home', page('home'));
1 Like

Great, thanks! :slight_smile:

This works even better in my case:

$collection->prepend('home', page('home'));

(I’m using it for a top menu where home comes first)