torf Posted May 9, 2023 Posted May 9, 2023 I have no idea if that is even possible, but I run into a problem with planning ahead the structure every now and then: If I have multiple templates that use the same field I try to reuse my fields of course. So let's say I have the field: myPictures (Images / jpg / max 5 images / ...). I use that field with different descriptions in multiple Templates. Now the site is in use, and after some month the client decides that in one template there need to be 8 possible upload slots with only png allowed. Now I'm stuck. If I change the field it changes for all, if I make a new field I loose all the uploads that already have been made for this template, if I'm going the safe way and add different fields for every template from the beginning I get to many fields that are maybe never needed. Is there any solution for that problem?
dynweb Posted May 9, 2023 Posted May 9, 2023 I would add a new field with your requirements and migrate the contents from the "old" to the "new" field. Here is how I did it for a migration from a single image ("image") to a multiple images ("images") field: $gearPages = $pages->find("template=products-view-gear, include=all"); foreach($gearPages as $p) { if($p->image) { $p->of(false); $p->images->add($p->image); $p->save(); } } 1
Robin S Posted May 9, 2023 Posted May 9, 2023 1 hour ago, torf said: Now the site is in use, and after some month the client decides that in one template there need to be 8 possible upload slots with only png allowed. You don't need a different field for this scenario. You can use template overrides for the field settings. In the field settings (Overrides tab): Then from the template settings, edit the field in template context: 3
torf Posted May 9, 2023 Author Posted May 9, 2023 Oh! I just did not realize that one. Thanks a lot! 1
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now