Repeater-Set pair for single element

Hi everyone, I am building a Nextjs website using Cockpit as backend. It works great! I have a “Pages” collection which contains top-level pages, for example “About”, “Events”… Currently every page has a “template” field which is used during the build process to select the template to use to render that page. In this phase every template requests a custom fixed set of data from the backend. I would like to skip this and provide the data directly inside the template. It seems that the “Repeater-Set” pair fits my use case: the Repeater field lets me choose the template to use based on a collection of Set fields, then every Set field provides a custom form to fill the data every template needs. I just did a proof-of-concept and it already works just fine. Since in the future I won’t be the one who will add pages nor edit their content I would like to offer the cleanest UI available. For example, the user must not be able to add more than one element to the Repeater field. Currently I have set “limit” option to “1” but the button used to add elements still shows up whenever that limit is reached. An Option field which behaves like the Repeater one makes more sense for this use case.

What do you think? Every thought is very much appreciated, thank you very much!

What do you mean by fixed? Shouldn’t the template content inclusion be dynamic? I don’t use nextjs, but use 11ty, and for the backend I have many different types of pages. I have free form pages (the user has one big markdown field to build content that gets injected into the page - I use these mostly for singletons(your top level about, etc. pages)) and I have structured pages, where I define all of the field types the user can provide entries to. I’m not sure what issue you are trying to solve using repeater sets.

I should not have written “fixed set of data”. It is the query the templates make that does not change, not the fetched data itself.

Every page employs a template to render its content. For the sake of example assume there are two templates available to the backend user: one displays some info about a person (i.e. an item chosen from a collection); the other shows a gallery of images, iterating a collection whose items have a field named “image”.

These templates must be fed different data: the first needs an item picked from a known collection, the second a generic collection.

Before the “repeater/set nested field” thing I could not choose which item and which collection to use. The only thing I could do was just telling the frontend to use this or that template, not which item or which collection to use. Now, using the “repeater/set” thing, if I want the page to display info about someone, I can select the template first and then I can choose the person using a collectionlink field. The same happens when I need to create a page that uses the “gallery” template.

Only one template is needed for every page, so instead of a set field nested to a repeater field whose “limit” option is 1 (to prevent multiple instances), it would work better a set field nested to an option field.

I hope I was a little clearer, thanks for your patience. :sweat_smile: