Hi, I’m fairly new to using Kirby with an API.
Is there a possibility to create a custom endpoint that provides me with all pages of a given template? This is how I tried it until now:
<?php
Kirby::plugin('my/api', [
'api' => [
'routes' => function($kirby) {
return [
[
'pattern' => 'my-endpoint',
'action' => function () use ($kirby) {
return [
'users' => $kirby->site()->index()->filterBy('template', 'myTemplate')
];
}
]
];
}
]
]);
Thanks a lot in advance!
PS: maybe a different topic, but related: $kirby->page(‘myPage’) as well as $kirby->page(‘myUuid’) don’t work for me. Am I doing something wrong here, or how do I get a certain page