I’ve been using querys to make a list of all children of a page including all Drafts like this:
query: page.childrenAndDrafts
But now I need to do the same with with all grandChildren and Drafts i’ve tried these:
query: page.grandChildrenAndDrafts
Returns this error:
Invalid query result - Result must be of type Kirby\Cms\Pages, Kirby\Cms\Field given.
query: page.childrenAndDrafts.childrenAndDrafts
Returns this error:
Invalid query result - Result must be of type Kirby\Cms\Pages, NULL given.
query: page.children.childrenAndDrafts
Returns this error:
Invalid query result - Result must be of type Kirby\Cms\Pages, NULL given.
I dont really get why these error get thrown. To me this makes sense since I want the children of the current page and then get all children of that page including all drafts.
Is there another way to do this or is my syntax just wrong?
Since when I place my function into the kirby core src folder Page Class (kirby/src/cms/page.php) the method can then be used in the blueprint. This is the function when I place it there:
public function grandChildrenAndDrafts() {
return $this->children()->children()->drafts();
}
But when creating a new class to extend the core Page class like this:
class GrandChildrenModel extends Page {
public function grandChildrenAndDrafts() {
return parent::children()->children()->drafts();
}
}
For some reason I cant use it in my blueprint and I still get the following error:
Invalid query result - Result must be of type Kirby\Cms\Pages, Kirby\Cms\Field given.
I have created a file inside /site/models/ named “endkunden.php” since the page in the backend that needs to use this function is called endkunden.txt and uses the template “endkunden”
Same error. It seems no matter what I write into this function it just wont work even when just returning $page or $pages
This code even works when adding it to the core kirby page class:
public function grandChildrenAndDrafts() {
return $this->children()->drafts();
}
To me it seems like the Model just doesn’t get registered. Even though the file is named exactly like the page template and it is in the correct folder.
No matter what i try to return in my method I wont get a result in my backend.