If I'm making a blog, it's obvious that I need a Post collection, where each document represents a single article.
But what if I'm making a general-purpose marketing site where I have a few different pages that all have different designs and therefore need different fields for content? These solutions pop in my mind:
The first approach seems the most rational, but what bothers me is that I'd have a collection with just a single document inside. Kind of like the Global collection. Does that make sense? Or there's a better way?
Great question! I would head on over to the demo.payloadcms.com example and see if that accomplishes what you want. On the pages collection there is a design templating approach that is very flexible by giving content authors a choice of different layouts and using content blocks to make pages that are very composable.
All the source code for the project is available too so take what you like and delete or modify the rest. It is found at https://gitbub.com/payloadcms/public-demo
Does that help?
You could also consider making a field in the pages collection called design
as a select or radio type. Then use the conditional properties so that your design specific fields are only used when needed.
That would be a good approach if you don't want to give as much editor control as the public-demo has.
Sounds great, thanks!
Star
Discord
online
Get help straight from the Payload team with an Enterprise License.