Here I am migrating a site from k2 to k3 and I have three pages with a lot of subpages, and each subpage with a lot of files, say:
A-parent
A-child + images
...
B-parent
B-child + images
...
C-parent
C-child + images
...
And the images in A,B,C have different field needs.
How do I batch add a blueprint to all the files in all children of A, another to B, etc?
Thanks
I should add that as I am migrating, most of these files already have their .txt with their diverging ammount of fields, for example:
Category:
----
Caption: blabla
So, all files in A-parent or B-parent etc. do not have the same fields? What does it depend upon which fields were assigned? After all, as far as I remember, the fields for files were defined in the blueprint of the parent page?
I’ve been checking these files and their fields.
There are:
Under some subpages the PDF’s have a select field with the options:
What I probably need to do is to create three new file bp
- img.yml (accept images, with only a caption field already present in the content files)
- cv.yml (accept pdf, no fields)
- press.yml (accept pdf, no fields)
I should, then, build a collection of all the files in every page, use $file->type() to filter images from pdf’s, and filter the pdf’s using the category field. Then how do I change the template, $file->update() ?
Thank you
@texnixe I am not sure I understand the note about the immutability of kirby objects such as $file in the $file->update() reference page:
This code…
$aFile->update([
'template' => 'image'
]);
…will modify the file’s content txt?
Thank you.
Yep, that’s correct.
IIRC the immutability is only for the php object; so if you update a file object via the update()
-method, the file’s content file is updated but the php object not! So if you need to do subsequent things with the updated object, you’ld have to use another variable to do so.
Ah I see, I understand now.
Thank you @bvdputte