.SHARP{C#DERS}

.net development, server management, and related topics

Umbraco page count document tree

After using Kentico for a number of years I got used to having easy access to the number of documents per site. In the process of migrating content between content management systems I needed a way to show the number of documents overall and per node. This allows me to split up work based on the actual volume of content. To do this I created this simple Umbraco package which shows all published nodes with a count of child nodes and the document type of each node. 

Here is a screenshot of the output.
If you are using Umbraco 6, you may need to save this as descendants.cs in your app_code folder. Umbraco 7 has it by default.

    
      /// 
       /// Make the All Descendants LINQ queryable
       /// 
       /// 
       /// 
       public static IEnumerable<Node> AllDescendants(this Node node)
      {
         foreach (Node child in node.Children)
         {
             yield return child;
               
              foreach (Node grandChild in child.AllDescendants())
                   yield return grandChild;
          }
     }
Page_count_document_tree_1.0.zip (1.8KB)
Comments are closed