I created a custom “page”/post type. So I can create posts via the Panel.
This works as expected.
I want to supplement the local posts with content from a JSON API. I followed the merging content guide.
However, when opening the Panel the virtual pages (i.e., the items from the API) are listed in the Panel and physical versions of them exist in the /content folder.
Is this normal?
I don’t want these items in the Panel at all.
Thanks for any assistance!
Merging content refers to one child page having local and virtual content, e.g. if you want to add local images to a page that would otherwise not exist in the file system.
I’m not sure if this is what you want to achieve? Or do you just want to mix virtual pages and normal pages? Thanks for clarifying.
make sure to pre-set the uuid for virtual pages or file copies are created.
I would like to supplement the existing page’s children with additional content from a 3rd party.
E.g. A blog page where some posts are created via the CMS and some are fetched from an API.
The 3rd party content should never be on disk.
yeah. thats the uuid issue you are facing. make sure to set them manually for your virtual pages.
I’ve marked this as solved (no files are created on disk!) but I just have one small issue.
The images uploaded to the page is not accessible via the frontend.
E.g., I have a field named
Uploading the file correctly attaches and creates it in the relevant /site/content/… directory
However, I can’t seem to access it on the frontend. Using
$page->cover_image() returns the Field Object
string(25) "- file://the_file_uuid"
$page->cover_image()->toFile() returns NULL.
$page->cover_image()->url() just returns the Field Object.
Am I doing something wrong? In the Page models when merging the content I set the local (i.e. panel) content like so:
$all = [
'slug' => $slug,
'num' => $idx+1,
'template' => 'event',
'model' => 'event',
'content' => $page->content()->data(),
return Pages::factory($all, $this);
What I’m missing in your code is the
files key, as shown in the model here: Merging content sources | Kirby CMS
That was it. I’ve been over the code so many times and missed that every time.
Thank you so much!
While the image shows on the frontend (via
$image = $page->image() and not
$image = $page->cover_image()) the Panel shows a broken image icon.
Additionally, when attempting to edit a page I get the following error:
The page directory cannot be moved