Hi, would it be possible to be able to enable a preview for singletons, the same way it works for collections? Passing the JSON data to a chosen url.
I’m currently building a one pager for a client that pulls everything from singletons, and it would great for them to be able to live preview the changes.
Ah yeah, I’ve thought about it. They’re all completely different sections, though, on one page. Like there’s a header, a menu card (it’s a restaurant), a gallery and a footer. It did not seem like it would make much sense to use collections for this, since there’s no reusing or repeating content types.
I’m curious how you would normally structure with a single page collection, accounting for different content types? Could use “layout” or “layout-grid” blocks, but we usually like to deliver a pretty locked down site, with the client only editing text blocks and images and the likes. Singletons work pretty well for this type of site that’s pretty static, and is easy for clients to manage.
Yes, I understand your requirement, a better approach would be with layout field indeed! But since you want to limit editor actions makes it more complicated.
The purpose of singletons is to feed other parts of the frontend implementation, usually site settings, SEO fields, etc… So a preview doesn’t seem logical, you can ask @artur for a feature request, but also don’t think he would agree.
There are a few other options:
you can have a homepage collection that links to the singleton (via singletonselect field), but you still need them to access the collection entry to open the preview
same as above, but you split the site into different singletons (header, main sections, footer), but maybe too clunky tbh
you can have a homepage collection with same fields as the singleton, and you give permissions to only view and edit entries and not create/delete to the editors, so for editors it will be always only one entry (that seems the more reasonable option)
I do understand the purpose of singletons – one thing I love about Cockpit is how “hackable” (or customizable) it is, though, so I thought maybe I wasn’t the only one to work around its intentions like this
@tao you aren’t the only one, I ran into this need as well. A little late, but I was able to put together a working content preview for singletons - files and instructions on github:github.com/CyanLetter/cockpit-singleton-preview
This may not be the right way to do things, since it requires modifying the singleton module files directly, but hopefully this helps anyone who just needs a quick fix.