Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Saied 349 posts 674 karma points
    Feb 11, 2016 @ 16:39
    Saied
    0

    A package to see what doc types, templates, etc are not being used?

    Hi,

    I am looking to do some clean up of my Umbraco instance. Is there a package that will let me see what nodes, doc types, templates, etc are not being used so that I can safely delete them?

    Thanks, Saied

  • Nik 1617 posts 7263 karma points MVP 7x c-trib
    Feb 11, 2016 @ 17:02
    Nik
    0

    That depends, there are a couple of packages available (if you look in the Projects section of this site you should find them) that work to a degree in Umbraco 7.

    I say to a degree as if you are using the grid they might not search in it. This means you need to be careful. The same goes for Leblender and Archtype objects.

    These are two packages available:

    • Umbraco Backoffice Visualization
    • RB - Umbraco CleanUp Manager
  • Daniel 60 posts 174 karma points
    Feb 11, 2016 @ 19:27
    Daniel
    0

    I wonder if this is as easy to code as:

    //Find
    var unusedContentTypes = Services.GetAllContentTypes().Select(x => Services.ContentService.Count(x.Alias) > 0);
    
    //Show
    <p>Unused doc types:</p>
    @foreach(var unusedContentType in unusedContentTypes ){
        <p>@unusedContentType.Name</p>
    }
    

    Would be a fun experiment!

  • Sotiris Filippidis 286 posts 1501 karma points
    Sep 08, 2017 @ 18:35
    Sotiris Filippidis
    0

    Well it's not so simple, but it's close.

    A better (yet not perfect) version would be:

    var cts = ApplicationContext.Services.ContentTypeService;
    var cs = ApplicationContext.Services.ContentService;
    
    
    //Find
    var allUsedAliases = cs.GetRootContent().SelectMany(y => y.Descendants()).Select(x => x.ContentType.Alias).Distinct();
    var unusedContentTypes = cts.GetAllContentTypes().Where(x => !allUsedAliases.Any(y => y.Contains(x.Alias)));
    

    And this won't still take into account:

    • The home page (the root node). That's because I'm lazy :)
    • Any nodes that are used only in compositions
    • Any nodes that are used only in Nested Content or similar data types (if any)

    Needs work, but I suspect it won't end up in something overly complicated.

Please Sign in or register to post replies

Write your reply to:

Draft