I tried to get a subpage with
findPageOrDraft() like this:
But it return NULL
If I use
findPageOrDraft() is not supposed to return a page or a draft?
findPageOrDraft only works for the direct children, not with a path.
So if you have a draft with the slug
Kirby will find it.
But the doc says
findPageOrDraft() takes a “path” in parameter:
and to get a direct child there is already the method
My “proposal-a” subpage is in
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.
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. Maybe this is a bug? @texnixe
What you can do