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.
bnomei
April 18, 2023, 12:10pm
3
make sure to pre-set the uuid for virtual pages or file copies are created.
opened 05:14PM - 13 Nov 22 UTC
closed 08:10PM - 16 Apr 23 UTC
**Issue with Reference**
Any virtual pages guide/docbook is currently broken,… in the sense that if a programmer doesn't add a **self generated uuid** to the content array of the virtual page, kirby generates the uuid and that triggers the creation of an actual page - folder and file in the filesystem.
**Expected**
"Since 3.8.1: You must include a 'uuid' in your content file"…
**Additional note**
I'm emphasising "self generate" uuid, because the first thing I tried was of course `'uuid'=>Uuid::generate()`, but that seems to trigger the file/folder creation as well.
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.
bnomei
April 18, 2023, 12:15pm
5
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 cover_image
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
object(Kirby\Cms\Field)#(1) {
["cover_image"]=>
string(25) "- file://the_file_uuid"
}
But using $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:
Exception: Kirby\Exception\LogicException
The page directory cannot be moved