I just love the new feature which allows you to change document type on content in Umbraco 7. This feature makes it easier to clean up old Umbraco sites after an upgrade. Nice! :-)
This leads to my question. Is there a way to keep track of document types that are not in being used anymore?
Loop through each document type, and do a XPath lookup in the XML cache
In code this would look something like:
IContentTypeService service = UmbracoContext.Current.Application.Services.ContentTypeService;
UmbracoHelper helper = new UmbracoHelper(UmbracoContext.Current);
foreach (IContentType contentType in service.GetAllContentTypes()) {
<p>@contentType.Alias: @(helper.TypedContentAtXPath("descendant-or-self::" + contentType.Alias + "[@isDoc]").Count())</p>
}
Depending on your XML cache, this might take some time (took a few seconds for a installation with 30k nodes). Also notice that this will only work if all documents are in the XML cache, and it won't look at documents in the recycle bin.
Document Types usage count
Hi
I just love the new feature which allows you to change document type on content in Umbraco 7. This feature makes it easier to clean up old Umbraco sites after an upgrade. Nice! :-)
This leads to my question. Is there a way to keep track of document types that are not in being used anymore?
My approach would be something like:
In code this would look something like:
Depending on your XML cache, this might take some time (took a few seconds for a installation with 30k nodes). Also notice that this will only work if all documents are in the XML cache, and it won't look at documents in the recycle bin.
Thanks Anders
The site I'm upgrading only has about 2k nodes, so no problem running your snippet. It does exactly what I needed, thanks :-)
Anyone running this snippet, remember the using statement:
is working on a reply...