Copied to clipboard

Flag this post as spam?

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


  • Ian Naylor 6 posts 57 karma points
    May 29, 2015 @ 11:02
    Ian Naylor
    0

    Update Content tree from Custom Section

    Hi,

    I have created a custom section that I use to create new sites in umbraco, using the content service.

    This all works.

    However, when I go to the Content section I can only see the new site if I right click and Reload Nodes.

    Is it possible to trigger the Reload Nodes functionality on the Content section from my custom section so that when I go to the Content Section my new site is visible?

  • Sören Deger 733 posts 2844 karma points c-trib
    May 29, 2015 @ 11:13
    Sören Deger
    0

    Hi Ian,

    I think you can do this with the navigationService: http://umbraco.github.io/Belle/#/api/umbraco.services.navigationService

    I have use this in a similiar case a few month ago:

    navigationService.syncTree({ tree: 'myCustomTree', path: [-1, $scope.myNode.id], forceReload: true }).then(function (syncArgs) {
                               navigationService.reloadNode(syncArgs.node);
                           });

     

    Hope this helps?

     

    Cheers,

    Sören 

  • Sören Deger 733 posts 2844 karma points c-trib
    May 29, 2015 @ 11:27
    Sören Deger
    0

    Hi Ian,

    at first I think you need navigationService.changeSection(sectionAlias) to change to the content section.

     

    Cheers,

    Sören

  • Ian Naylor 6 posts 57 karma points
    May 29, 2015 @ 13:39
    Ian Naylor
    0

    Hi Soren,

    First of all thanks for the help

    Secondly, sadly I am still stuck.

    Every time I try to call the syncTree method I get an error message saying "Could not find the tree content, activeTree has not been set".

    I have even tried using the treeService to get the correct name of the tree alias (see below) and it still raises the same error, can you spot what I am doing wrong or have any other ideas?

     

    treeService.getTree({ section: 'content' }).then(function (tree) {

                            navigationService.changeSection("content");

                            navigationService.syncTree({ tree: tree.alias, path: [-1], forceReload: true }).then(function (syncArgs) {

                            navigationService.reloadNode(syncArgs.node);

                            navigationService.changeSection("customSection");

    });

    }); 

  • Sören Deger 733 posts 2844 karma points c-trib
    May 29, 2015 @ 14:11
    Sören Deger
    0

    Hi Ian,

    why do you will change back to customSection at the end? Maybe you must wait for the promise after change section to content like this:

    navigationService.changeSection("content").then(function(syncArgs) {
    navigationService.syncTree.............
    .........
    });

    I can't test this at moment and because this I don't know if this will work. But I would go this way ;-)


    Cheers,
    Sören 

  • Ian Naylor 6 posts 57 karma points
    May 29, 2015 @ 15:14
    Ian Naylor
    101

    Got it working....sort of

    The changeSection method isnt a promise so I couldnt add a "then" function.

    But it looks like you have to allow nthe changeSection functionality to complete, so you are on the correct section before you call the syncTree functionality.  It looks like the syncTree functionality only works for trees that are for the section you are currently on.

    So the only way I could see to enforce this was to use a "setTimeout" after the changeSection, and then call the syncTree functionality.  Its a little nast but it works

     

     navigationService.changeSection("content");

                        setTimeout(function () {

                            navigationService.syncTree({ tree: 'content', path: [-1, siteId], forceReload: true , activate:true}).then(function(syncArgs) {

                                navigationService.reloadNode(syncArgs.node);

                            });

                        }, 100);

     

    Oh and I was changing back to my customSection at the end so that the user would still be on the same section they were using to create the as there might have been more steps that needed to be carried out in that section after the site was created.  However, thinking about it I dont think it is needed and it makes more sense to see the new site in the content section.

    Again thank you for all you help

  • Sören Deger 733 posts 2844 karma points c-trib
    May 29, 2015 @ 15:28
    Sören Deger
    0

    Hi Ian,

    great to hear that you have solved it and thanks for sharing your solution!

     

    Cheers,
    Sören 

Please Sign in or register to post replies

Write your reply to:

Draft