# Preview for singletons

**URL:** <https://discourse.getcockpit.com/t/preview-for-singletons/1247>\
**Category:** Feature Request\
**Created:** [March 5, 2020, 2:11pm UTC](https://discourse.getcockpit.com/t/preview-for-singletons/1247 "2020-03-05T14:11:43Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![tao](https://avatars.discourse-cdn.com/v4/letter/t/f9ae1b/32.png) [@tao](https://discourse.getcockpit.com/u/tao)\
**Post date:** [March 5, 2020, 2:11pm UTC](https://discourse.getcockpit.com/t/preview-for-singletons/1247/1 "2020-03-05T14:11:43Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![pauloamgomes](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/pauloamgomes/32/48_2.png) [@pauloamgomes](https://discourse.getcockpit.com/u/pauloamgomes)\
**Post date:** [March 9, 2020, 12:08am UTC](https://discourse.getcockpit.com/t/preview-for-singletons/1247/2 "2020-03-09T00:08:04Z")

</div>

Why to use singletons for that? Would not be better to have a single page collection? Singletons have a different purpose.

---

<div class="post-metadata">

**Author:** ![tao](https://avatars.discourse-cdn.com/v4/letter/t/f9ae1b/32.png) [@tao](https://discourse.getcockpit.com/u/tao)\
**Post date:** [March 9, 2020, 11:02am UTC](https://discourse.getcockpit.com/t/preview-for-singletons/1247/3 "2020-03-09T11:02:35Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![pauloamgomes](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/pauloamgomes/32/48_2.png) [@pauloamgomes](https://discourse.getcockpit.com/u/pauloamgomes)\
**Post date:** [March 10, 2020, 10:30pm UTC](https://discourse.getcockpit.com/t/preview-for-singletons/1247/4 "2020-03-10T22:30:56Z")

</div>

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)

hope that helps

---

<div class="post-metadata">

**Author:** ![artur](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/artur/32/4_2.png) [@artur](https://discourse.getcockpit.com/u/artur)\
**Post date:** [March 18, 2020, 7:47am UTC](https://discourse.getcockpit.com/t/preview-for-singletons/1247/5 "2020-03-18T07:47:52Z")

</div>

a preview option for singletons is not planned, sorry. singletons are thought to be as Paolo mentioned for generic settings etc.

---

<div class="post-metadata">

**Author:** ![tao](https://avatars.discourse-cdn.com/v4/letter/t/f9ae1b/32.png) [@tao](https://discourse.getcockpit.com/u/tao)\
**Post date:** [March 18, 2020, 10:12am UTC](https://discourse.getcockpit.com/t/preview-for-singletons/1247/6 "2020-03-18T10:12:05Z")

</div>

@pauloamgomes Thanks for your response! Very good points, the last one does seem the best option. I might have to reconsider my needs, as well.

@artur No worries, thanks anyway!

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

---

<div class="post-metadata">

**Author:** ![CyanLetter](https://avatars.discourse-cdn.com/v4/letter/c/919ad9/32.png) [@CyanLetter](https://discourse.getcockpit.com/u/CyanLetter)\
**Post date:** [September 10, 2020, 12:14am UTC](https://discourse.getcockpit.com/t/preview-for-singletons/1247/7 "2020-09-10T00:14:36Z")

</div>

@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](https://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.
