Can't get draft subpage with findPageOrDraft()


I tried to get a subpage with findPageOrDraft() like this:


But it return NULL

If I use


It works!

findPageOrDraft() is not supposed to return a page or a draft?

Looks like findPageOrDraft only works for the direct children, not with a path.

So if you have a draft with the slug proposal-a in content/_drafts,


Kirby will find it.

But the doc says findPageOrDraft() takes a “path” in parameter:

$site->findPageOrDraft(string $path)

and to get a direct child there is already the method childrenAndDrafts()

My “proposal-a” subpage is in content/1_sydney/_draft so


does not works :-/

This is the method:

 public function findPageOrDraft(string $path)
        return $this->children()->find($path) ?? $this->drafts()->find($path);

So it searches in the children, not in the tree.

Ok, thanks @texnixe

Have to agree with @gillesvauvarin though, the docs should not call the argument the path but the uid (?) instead. I was just confused about the same thing, because the docs call it path, when clearly this does not take a full path.

@texnixe this just took me +1h haha. because the docs are not clear here. can confirm it’s only working with direct children. i guess it would be good if they were updated?


Well, but path is correct, because you can pass a path:


But a complete path still returns NULL if the page is a draft. :confused: Maybe this is a bug? @texnixe

What you can do