Hi,
We are trying to render a full representation of a specific page in a custom JSON format so that we can get its contents at any time, regardless of the current status. If the page is listed or unlisted, we can simply use the page method and pass the specific path to get the page object and work with it.
page('page/subpage/anotherpage/targetpage')
If the target page is in draft mode (or any at a higher level), it doesn’t work obviously – even if we try it with the Kirby impersonate method. If we know exactly at which level the specific page is and pass each page UID as a parameter to our custom route, we can run these chained methods to get the desired page:
<?php
page($LEVEL_1)
->findPageOrDraft($LEVEL_2)
->findPageOrDraft($LEVEL_3)
->findPageOrDraft($LEVEL_3)
->customPageMethod();
?>
This is unfortunately not practicable, because we don’t always know at how many levels the page is located in Kirby. Our goal is to be able to pass something like this:
/custom-endpoint?path=page/subpage/anotherpage/targetpage
to our endpoint and get a special prepared JSON representation of the page.
I know that we could use the official REST API for that, but the target system which is requiring the data is public and shouldn’t contain any API keys or tokens & should get a modified JSON that we need to prepare on the server where Kirby stays.
Is there any hidden method that I couldn’t find in the docs and we could use to achieve that? Maybe something like
pageOrDraft('desired/page/target')
?