Change status of a virtual page (CSV)

I have a problem where I just can’t get ahead. I am including a CSV file as a Virtual Page and have followed the tutorial for this (Merging content sources | Kirby CMS).

Everything works so far, but everything breaks down when the status of the Virtual Page is changed, for example from listed to unlisted.

The page is visible only as draft in the content folder, but it is still listed in the panel. Also - and this is the bad thing - all previously assigned image elements are deleted for entries that use the page model that is responsible for the import. They are still present in the content folder, but they are no longer displayed in the panel and frontend. Also the respective media folder with the corresponding hash is empty.

Does anyone have an idea how I could get ahead here?

The problem probably arises from the fact that the pages have a prepended number: 'num' => 0, so they are by default listed. Do all your virtual csv pages have a folder in the filesystem?

Yes. Image and text elements are added to each page.

Is there are reason why you use the virtual pages approach if you have a content folder for each entry anyway?

Yes. It might be be easier to do it vanilla kirby and I am considering it. But the integration of a CSV-file is the first step in automating the system. So having the option would be very welcome.

You would have to extend the model to make this work, or rather, you will need a model for the single page as well, to keep the virtual stuff and the stuff in the file system in sync. But I nevertheless wonder if it wouldn’t make more sense to create the pages from the csv file programmatically and if need be to update. But I don’t know your use case for using the csv data.

Thank you. I think I see the challenge here and I might try another approach.