Singletons vs Regions


#1

Hi.

I was using Cockpit several years ago, even provided and maintained an HR language file, and I remember using the Regions as snippets, for example, the site navigation menu.

Returning back to see what’s new, I discovered the Singletons introduction as the replacement for Regions but I cannot figure out how to use Singletons for the same example, the site navigation menu.

Any help would be appreciated.

Cheers,
Siniša Perović


#2

btw now there is an official addon that brings backs regions: https://github.com/agentejo/Regions


#3

Thank you @serjoscha87, I’ve read all of that but missed to find out where is the gain in having singletons over regions. Must dig deeper.

Cheers.


#4

Hm. For me Artur’s posts says it all. So what precisely are you missing in that explanation?


#5

Thank you @serjoscha87 for your time and effort here. I’m not newbie but not the professional either so bare with me please.

Well, as I wrote in my post, I remember using “old” Regions as snippets (like nav bar or footer). The name and code was all you need to create one.
The Singleton and “new” Region are the form builders. The “new” Region gives me Template where I can create my Snippets (although I don’t get why I need form to get it populated) and the Singleton is basically the same but without the Template.
Could you be so kind and give me few examples of intended use for both Singleton and “new” Region.

Thank you again for your time and effort.


#6

I’m afraid I am not able to give you some examples - I usually don’t use singletons and same with the regions back in the days. But I guess you are right - the main differnce is just that the template thingy fell away.
Guess thats all.

So basically now I think a collection is just a bunch of singletons.


#7

@WebShapedBiz, think you can use singletons as basic structures of information that are not repeating, for example, let’s imagine you want to be able to configure the footer of your website, maybe you can have a singleton with a bunch of fields:

Footer Links
Copyright Message

Now let’s imagine you want to store your site generic settings, you can have a singleton “settings” and store things like:

Site Name
Default homepage
Site Logan
Site Logo
Global Metatags
etc…

The difference to regions is already clarified by @serjoscha87, the addon now is irrelevant and its there only for legacy purposes.

Hope that helps.


#8

Thank you @pauloamgomes @serjoscha87 for your support. I managed to wrap my head around it. The form part was confusing for me, it seemed like an unnecessary overhead to the whole “snippet” concept but I can live with it.

Cheers.


#9

Helloo!

I’m starting to get the concept as well. But for a bit more concrete advice:

When I update my Cockpit instance from 0.7.0 to the latest version and already have a bunch of content in the database … uhm … can I convert regions to singletons?


#10

You can still use regions (just install the regions addon), to convert you may need to write a migration script, seems nothing too much complicated.