Just for info,
a page under home called āmyaudioā has a file attached called ācoolaudio.mp3ā.
If I add the āhasFilesā call to the API it shows ātrueā, now I want to return the file url at the same level
(hope itās clear enough haha)
The bit of code Iām trying to add is placed under
/**
Page
*/
return [
āfieldsā => [
So basically Iām trying to add this new property the same way we are calling
āidā => function (Page $page) {
return $page->id();
},
Iām trying to show the file URLs indeed, I donāt really mind if itās under the media folder or not, itās mostly to return the media URL without having to do a second API call.
To give a bit more context, I have created a new page here
/content/1_home/3_myaudio/
and added a mp3 file with it
/content/1_home/3_myaudio/coolaudio.mp3
Iām trying to display the mp3 URL when doing the API call:
So you are actually trying to modify Kirbyās source code? Doesnāt sound like a great idea.
If you want to treat the audio file as a child of the home page, it should rather be a virtual subpage of this page, define in the home pageās page model.