Hi all, I am using virtual files for my content pages and these files live pre-populated on a server. When I add a new page, Iād like to populate my files field with a reference to such a virtual file to not to have to select it manually, when the file exists. What do I need to set the file reference in the content file of my page?
Thank you!
You can use the $page->update()
method in a page.create:after
hook. The files field expects an array of file ids as input.
Than you, @texnixe!
I am not sure if this is the right way, but $page->update(['my-image-field' => $fileId])
works just fine.
And on existing pages I used my text editor and some regex and to add the field to the content file. Because of the virtual files that was easy and now I have 300 images correctly referenced as previews in the panel within 5 minutes!