Element Type vs Composition
j
When creating a doctype you get the options element type and composition, is there any difference under the hood? I am creating some compositions inside a migration so just wondering if there is anything else to consider. I've checked the database and both seem to be created the same just with a different default icon? Thanks ❤️
c
Hi Jamie! When creating a doctype, there is a distinct difference between the two. When selecting something as an Element, you make it so that that item shouldn't be used in the content tree, but should be used as part of a Nested Content/Block List/Block Grid element instead of a content item. Compositions on the other hand is like inheritance, where you define a "base" doctype, which you want your other pages to be based off of (Like a generic Page document with some SEO info, and a specific Blog item that is composed of Page)
j
Thanks @Corné Hoskam that's how I understand the usage intention of them yes, I more mean technically as it's stored in Umbraco is there any difference as I can't see any so wanted to double check
c
I don't think so no! As far as I know they're all just document types with a flag enabled whether they are an element or not, and whether a document is composed of another document
j
For example I am using the code below to create a doctype, so from what I can see they would both have IsElement type set to true and the rest the same. Obviously how we then use them will be different but the creation would be the same. Thanks @Corné Hoskam for checking, seems I am not missing anything 🙂
c
Glad I could help! If you want more of the technical side of things: The doctypes are stored in the cmsContentType table, which has a IsElement boolean field. For Compositions there is the cmsContentType2ContentType table which has a parentContentTypeId & childContentTypeId field 🙂
That's how those two properties are made up
j
Correct - that table is only populated once you use it as a composition, in my case the table is empty initially - thanks for going deeper into it, appreciated
177 Views