Copied to clipboard

Flag this post as spam?

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


  • Graeme W 113 posts 289 karma points
    Jan 03, 2018 @ 14:53
    Graeme W
    0

    Content Inventory

    I've been asked if it's possible to create a Content Inventory as outlined here https://www.usability.gov/how-to-and-tools/methods/content-inventory.html Is there any functionality within Umbraco to do this?

    If not, then resumably it's just a case of running a query on the database to get all published pages from the website then exporting to Excel In that case does anyone have a script that would do the trick?

    Thanks

  • Steve Morgan 1349 posts 4459 karma points c-trib
    Jan 03, 2018 @ 16:34
    Steve Morgan
    0

    This do you?

    It's my quick and dirty output all pages and count the doc types used. I usually just create a new doc type and template called test - pop this in the template body and then create the node, hit the page, copy the output then delete the node.

    @{ 
    
    
        // either set your home node ID or juse use the typed content at root
        var homeNode = Umbraco.TypedContentAtRoot().First();
        // var homeNode = Umbraco.TypedContent(1068);
    
        var allNodes = homeNode.DescendantsOrSelf();
    
        var docTypeCount = new Dictionary<string, int>();
    
    }
    
    <table>
        <tr>
            <th>Id</th>
            <th>Name</th>
            <th>DocType</th>
            <th>Url</th>
            <th>Some custom property</th>
        </tr>
        @foreach(var curNode in allNodes)
        {
            // increment the count if in dictionary or add new key if not
            int currentCount;
            docTypeCount.TryGetValue(curNode.DocumentTypeAlias, out currentCount);
            docTypeCount[curNode.DocumentTypeAlias] = currentCount + 1;
    
            <tr>
                <td>@curNode.Id</td>
                <td>@curNode.Name</td>
                <td>@curNode.DocumentTypeAlias</td>
                <td>@curNode.Url</td>
                <td>@curNode.HasValue("someProperty")</td>
            </tr>
        }
    </table>
    
    <hr/>
    <br/>
    @{ 
        <table>
            <tr>
                <th>Id</th>
                <th>Name</th>
            </tr>
            @foreach (var curKey in docTypeCount)
            {
            <tr>
                <td>@curKey.Key</td>
                <td>@curKey.Value</td>
            </tr>
            }
    </table>
    }
    
    <hr />
    

    Needs a copy and paste into Excel still ;)

    HTH Steve

Please Sign in or register to post replies

Write your reply to:

Draft