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?
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?
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
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.
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?
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:
Hope this helps?
Cheers,
Sören
Hi Ian,
at first I think you need navigationService.changeSection(sectionAlias) to change to the content section.
Cheers,
Sören
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");
});
});
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:
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
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
Hi Ian,
great to hear that you have solved it and thanks for sharing your solution!
Cheers,
Sören
is working on a reply...