OrchardCMS / OrchardCore

Orchard Core is an open-source modular and multi-tenant application framework built with ASP.NET Core, and a content management system (CMS) built on top of that framework.
https://orchardcore.net
BSD 3-Clause "New" or "Revised" License
7.36k stars 2.37k forks source link

[Design] Global content #438

Closed sebastienros closed 3 months ago

sebastienros commented 7 years ago

In a website there often is some content structure that is global to the site. The Site Name is an example, there is a unique instance, it's a well-known piece of data. But the site name is common enough that it's part of the settings. And the settings are not versionable or draftable.

What I want is a way to describe a custom data structure for a content item that is unique in the system (singleton content item), draftable (optionally) and versionable (optionally). Something to hold the data for things like Site description, company address, footer, copyright text, meta tags, custom scripts for the layout ... These can also be in different data structures (different publication workflows).

In O1 the solution is to use widgets but reusing the same content across the site needs complex layers.

Implementation

There is almost nothing to implement in Orchard to have this, we can just create a content type, and a content item. We just need some plumbing to make impossible to create more instances of this type than one, and probably some UI to show the item. The content item would also have an alias (it's not generally routable, but could be) so that views can reuse the item easily, and tokens too.

Right now I am not sure about the way to implement it, too many options. The most obvious way is a marker content part. The most simple one is to do nothing, just use a content type with an alias, and then prevent anyone from being able to create a new instance, no ui integration.

Some potential names to give some better explanation (if needed) would be:

jersiovic commented 7 years ago

:+1: Singleton part sounds good

sebastienros commented 7 years ago

A stereotype would not be appropriate even though it seems a logical solution (a different kind of type) as it would drive different shapes for editing and displaying, which could seem odd when using these.

agriffard commented 6 years ago

Does the CustomSettingsPart allow this kind of scenario?

deanmarcussen commented 5 years ago

So although they're based on stereotypes, I don't understand why the CustomSettings module doesn't already achieve all of this?

I've kind of done something similar to this in my own custom module, with a contentitem that's cached, which could be quite easily reused to achieve this, but I just had a good play around with the CustomSettings module, and it seems to achieve most of this already.

It is driven through ISite so doesn't have any display drivers, just editors, and I can place media fields and reuse all the other field editors, on it, which are then accessible through Site.Properties.

sebastienros commented 5 years ago

CustomSettings is code driven, not metadata driven. Or am I wrong?

hishamco commented 5 years ago

I can think of this as:

1- Global / Shared Content Type: which is a singleton content type that created once and used everywhere. This is useful to reuse the same content type across multiple tenants, instead of create it again and again

2- Global Content: which is a piece of data that can be used across multiple tenants, this can divided into:

2.1- Singleton Content: where the value shared across the tenants such as: PoweredBy, Version ..etc

2.2- Transient Content: where the value isn't shared, so each tenant can define it's own such as SiteTitle, Description, Keywords .. etc

Implementation:

1- Can be created in the default tenant only, and make them visible everywhere, by created a SharedContentTypes.json

2.1- Can be edited in the default tenant only

2.2- Can be edited in each tenant like any other content, but its content type is defined in SharedContentTypes.json

Piedone commented 4 months ago

CustomSettings is metadata driven in the way that you can create custom settings fully from the admin as well, just by using its stereotype.

Is this issue still applicable?

github-actions[bot] commented 3 months ago

It seems that this issue didn't really move for quite a while. Is this something you'd like to revisit any time soon or should we close? Please reply.

github-actions[bot] commented 3 months ago

Closing this issue because it has been stale for very long. If you think this is still relevant, feel free to reopen it.