Section Plugin - show grandchildren of a certain page

Hi there

I have question regarding custom section plugins. After a Kirby update, it seems page sections allow only a single parent. Before, I could use a collection of parents (hacky and was never supposed to work, but it did).

What the plugin should achieve:
It should show all listed grandchildren of a certain page that have a certain template. A simple list ist enough (I can use the existing panel components, no problem).

What’s not working:
I’m not sure how to best go about getting the data of the relevant grandchildren pages into vue. I thought I could use a regular kirby query in the computed props of the PHP file, like this:

'computed' => [
    'myPages' => function() {
        return kirby()->page('grandParentPage')->grandChildren();

but the result in vue is an object that has the correct page uids as keys, but is otherwise empty.

Then I thought it would be better to use the REST API, but there I can only find an endpoint for child pages.

Do I really have to query my grandParentPage for children and then query every child for its children or is there a better way for this in Kirby?

Any help to put me in the right direction would be greatly appreciated!

Are you aware that there is already a plugin for displaying any set of pages:

If you still want to roll your own, check out the source code of the plugin.

1 Like

No I wasn’t aware :sweat_smile:
That’s the perfect solution though, thanks a lot.