Copied to clipboard

Flag this post as spam?

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


  • David Zweben 265 posts 749 karma points
    May 03, 2018 @ 23:24
    David Zweben
    0

    I need to make a custom status page in the Umbraco backoffice that displays the entire site's content tree (with everything always expanded), and displays the publish state of certain types of nodes (those with document type aliases containing certain a certain string) via color coding.

    It seems like a custom Dashboard is the way to do this, but so far I haven't found any specific info on how I could output a customized content tree like this.

    I feel like if I could get some code set up that recursively outputs all child nodes as text labels, I could probably handle the rest, but I'm not too familiar with AngularJS, so I don't know how to do that.

    Is anyone able to point me in the right direction? Any suggestions or tips would be appreciated.

    Thanks,
    David

  • Dennis Aaen 4499 posts 18254 karma points admin hq c-trib
    May 08, 2018 @ 08:42
    Dennis Aaen
    1

    Hi David,

    Dont know if you have seen this before. We have some documentation on how to setup a custom dashboard.

    Hope you can get some inspiration and help from this guide - https://our.umbraco.org/documentation/tutorials/Creating-a-Custom-Dashboard/

    /Dennis

  • David Zweben 265 posts 749 karma points
    May 08, 2018 @ 19:59
    David Zweben
    0

    Thanks Dennis. I was able to get started by following those instructions, but I am stuck on how to get the root node of my website (or its ID), so I can get child content from it. I don't want to hard code an ID, because this will break across local/dev/live. Can anyone point me in the right direction?

    Thanks,
    David

  • Dennis Aaen 4499 posts 18254 karma points admin hq c-trib
    May 08, 2018 @ 20:42
    Dennis Aaen
    0

    Hi David

    Have you seen the content service https://our.umbraco.org/documentation/reference/management/services/contentservice#getrootcontent

    There is a GetRootContent() method

    Hope this helps,

    /Dennis

  • David Zweben 265 posts 749 karma points
    May 08, 2018 @ 20:45
    David Zweben
    0

    Hi Dennis,

    Thanks for the reply. I need to access the root node from within AngularJS in a custom Dashboard, though. ContentService is a C# API. Would I need to do something like set up a surface controller that uses the C# GetRootContent() method just to get the root node from within AngularJS?

  • Dennis Aaen 4499 posts 18254 karma points admin hq c-trib
    May 08, 2018 @ 20:51
  • David Zweben 265 posts 749 karma points
    May 08, 2018 @ 23:24
    David Zweben
    0

    Thanks, but unfortunately that won't work for me, because I don't have an initial node in the tree already at hand. My main issue is that I need to get some sort of entry point into the content tree so I can start traversing, without referencing a node ID.

    Does anyone have any idea how I could do this? I don't see any methods that look to be of much help in the API documentation.

  • David Zweben 265 posts 749 karma points
    May 08, 2018 @ 23:38
    David Zweben
    0

    Looks like I found a way in! Here's the code I used:

    angular.module("umbraco").controller("TranslationsDashboardController", function ($scope, entityResource, contentResource, treeResource, treeService) {
    
        var vm = this;
    
        treeService.getTree({ section: "content" })
            .then(function (content) {
                console.log(content);
            });
    
    });
    

    In the console I then get an object for the root of the Content section tree (above even my Homepage node), which I can then get the child nodes of to start traversing.

    EDIT: Upon looking at the results, it looks like I could've also used the node ID "-1" to get the same node by ID.

Please Sign in or register to post replies

Write your reply to:

Draft