OrchardCore icon indicating copy to clipboard operation
OrchardCore copied to clipboard

Feature Request: Namespaces/categories for content type definitions

Open JoshTango opened this issue 5 years ago • 20 comments

I think it would be a good idea to have the content definitions grouped into namespaces or some container strategy. For example all the blog content types can go in the Blog namespace and all the regular website content types can go in a website namespace and all the product content definitions can go in a Product namespace

This problem arose when I liked the agency recipe for the website but I need other definitions for blogging and I need other definitions for products. Switch or deciding between recipes doesn't make sense because I need all the content definitions from multiple recipes.

Currently it looks really messy for all these different categories of content definitions. It would be nice if they were grouped by synergy.

JoshTango avatar Nov 14 '19 17:11 JoshTango

We talked about adding a Category metadata to types, like we have Stereotypes, which would let us group Widgets for instance. Would that solve your issue? We would use this category in the admin screens to group types.

sebastienros avatar Nov 14 '19 18:11 sebastienros

the admin screen is most important.

JoshTango avatar Nov 14 '19 19:11 JoshTango

Yes, that was the context of my comment

sebastienros avatar Nov 14 '19 19:11 sebastienros

I guess my next question would be an xml hierarchy question in the recipes and content definition file. Would you have parent xml nodes for these categories? Or would you just keep one linear list of content types? This is more of an implementation thing.

JoshTango avatar Nov 14 '19 19:11 JoshTango

Categories would be seen as a flat list of content types. Just groups of one level. A property for each content type.

sebastienros avatar Nov 14 '19 19:11 sebastienros

I assumed so. I guess no big reason to stray from that.

JoshTango avatar Nov 14 '19 20:11 JoshTango

If someone finds the issue that talks about it already, please reference this one

sebastienros avatar Nov 14 '19 20:11 sebastienros

I was also thinking about micro frontends. This would address the data schema aspect of a micro frontend I suspect? Now that 1.0 is out will this issue be on the agenda? @sebastienros

JoshTango avatar Aug 08 '21 15:08 JoshTango

I think prefixing Content Types technical names might be a good approach for this as of now. Then, adjust the admin UI in consequence. Else, having the same technical name for different Content Types might get messy over time. Also, having a dependency on a parent category to decide which Content Type is what might require some breaking changes. I'm not against it, but it might be a bigger challenge going that path so I think the prefix is simpler to implement.

Also, adding a category on Content Types might lead to needing complex hierarchy of categorization like "taxonomies" over time. So, the idea here is to be able to have multiple Content Types which have a similar name and function but with slight differences between them. So, regrouping them in different containers would allow using the same technical name in each containers for micro frontends type of use cases.

Skrypt avatar Aug 10 '21 05:08 Skrypt

Ok but would it use periods or underscore? Forum.Post Forum.Contact CRM.Contact for example?

JoshTango avatar Aug 10 '21 12:08 JoshTango

And the next issue would be more than one prefix for example:

companyname.microfrontendname.contentypename

JoshTango avatar Aug 10 '21 12:08 JoshTango

You can fake namespaces by removing the dot which is not allowed. Will be the same in the end. As for the UI, the only thing we can do is add a category as I suggested, which could then be used by some admin screens.

Category: string This can be done anytime and won't break anything.

sebastienros avatar Aug 12 '21 17:08 sebastienros

While category is fine, I still think something more official along the lines of namespaces is preferred. Maybe underscore is used and the admin UI shows this in a tree. The current problem is I think the admin shows display name and not technical name which is another issue.

JoshTango avatar Aug 12 '21 18:08 JoshTango

Well maybe a field called Namespace is added. Internally the List holding the content type names could stay the same and you could make a different structure for holding content types which have a namespace != null. I suppose you could put a single wrapper class around both lists.

Then there would have to be a bunch of if statements(if namespace != null) sprinkled all over the code including queries.

JoshTango avatar Aug 17 '21 22:08 JoshTango

So namespace is exactly like category? However handling hierarchies is harder in terms of UI. Nothing prevents you from having underscores or even dots in a category. I would keep the word category as namespace is very much only used in C#.

sebastienros avatar Aug 19 '21 17:08 sebastienros

well whatever strategy is used it needs to allow duplicate content type names which would cause collisions.

JoshTango avatar Aug 19 '21 17:08 JoshTango

Ok lets rename namespace to subdomain because thats what this is really about: Domain Driven Design.

JoshTango avatar Aug 20 '21 12:08 JoshTango

Actually lets just stick with PACKAGE as the field name. There is no need to show the entire heirarcy in the Admin UI. Just one level for the package name and then the content types below it in a liner list. You dont have to show a treeview for each period.

JoshTango avatar Aug 26 '21 11:08 JoshTango

I guess I can settle for category now. @sebastienros

In the future I would like a discussion on domain types.

JoshTango avatar Sep 25 '21 21:09 JoshTango

Duplicate by https://github.com/OrchardCMS/OrchardCore/issues/11556. See it for some more notes.

Piedone avatar Apr 28 '24 22:04 Piedone