How can I identify what element types a doctype uses? - v12 C# API
I made a dashboard for reporting on where each Content Type (doctype) is used (in terms of content nodes) in our Umbraco 12.0.0 installation. This is going to be helpful to clean up configuration that isn't being used, or isn't being used much.
The problem I'm having is that we have a lot of "Element Types" that are being used, but since they're element types, they're used inside of properties, instead of directly on the Document Type. I can figure out Doctype usage by looping through content nodes and looking at their "ContentType" property, but the Element Types are showing as being unused, when that's not really true. The problem is, I don't see any good way to figure out what Document Types the Element Types are used in.
I'm using the IContentTypeService to get data on the Document Types. Those IContentType objects contain a lot of data on the properties, but I don't see any clear way to pull out the Element Type aliases, unless maybe I hard-code the Data Type Alias of every property editor that uses Element Types, and dig through their data for the Element Type alias.
I'm pretty sure the answer is just "no", so I started doing it the way I said above. I'm getting all the properties of a doctype that have the editor alias "Umbraco.NestedContent", getting their DataTypeId, using that ID to look up the DataType from IDataTypeService, drilling down in the configuration info for the content type alias. It'll require slightly different code for each type of property that uses "Elements" to dig out the property alias, which is unfortunate, but it does seem to work.
Have certainly used it to see whether Data Types are in use, what I can't remember is if its clever enough to find element types used in block list /nested content etc..
How can I identify what element types a doctype uses? - v12 C# API
I made a dashboard for reporting on where each Content Type (doctype) is used (in terms of content nodes) in our Umbraco 12.0.0 installation. This is going to be helpful to clean up configuration that isn't being used, or isn't being used much.
The problem I'm having is that we have a lot of "Element Types" that are being used, but since they're element types, they're used inside of properties, instead of directly on the Document Type. I can figure out Doctype usage by looping through content nodes and looking at their "ContentType" property, but the Element Types are showing as being unused, when that's not really true. The problem is, I don't see any good way to figure out what Document Types the Element Types are used in.
I'm using the IContentTypeService to get data on the Document Types. Those IContentType objects contain a lot of data on the properties, but I don't see any clear way to pull out the Element Type aliases, unless maybe I hard-code the Data Type Alias of every property editor that uses Element Types, and dig through their data for the Element Type alias.
Is there an easier/cleaner way to do this?
I'm pretty sure the answer is just "no", so I started doing it the way I said above. I'm getting all the properties of a doctype that have the editor alias "Umbraco.NestedContent", getting their DataTypeId, using that ID to look up the DataType from IDataTypeService, drilling down in the configuration info for the content type alias. It'll require slightly different code for each type of property that uses "Elements" to dig out the property alias, which is unfortunate, but it does seem to work.
Hi David
I'm wondering if GodMode does this..?
https://github.com/DanDiplo/Umbraco.GodMode
Have certainly used it to see whether Data Types are in use, what I can't remember is if its clever enough to find element types used in block list /nested content etc..
Regards
Marc
is working on a reply...