Hello! I'm currently trying to create a custom tree and I'm running into trouble when trying to render a nodes children. After browsing various articles/posts I'm at this point:
The code above gets the article belonging to the current user (for the sake of testing, each user only has one article at the moment). I then attempt to print out the children of this article but instead of getting the desired output, I get the follwowing:
Article Name - Article Name - Article Name - Article Name
Each time I expand a node, it just seems to render the same node, and goes on and on.
I've seen other ways of using the treeservice, like:
xNode.Source=string.Format(IOHelper.ResolveUrl(SystemDirectories.Umbraco)+"/tree.aspx?rnd={0}&id={1}&treeType={2}&contextMenu={3}&isDialog={4}&isProduct=true",Guid.NewGuid(), categoryEntity.CategoryId,TreeAlias,ShowContextMenu,IsDialog); Could you explain a bit more about this?Many Thanks,
Yes xNode.Source is used to render children. When you try to open a child node "public override void Render(ref XmlTree tree)" is called again, but with different values. That's why I add "&isProduct=true" to the querystring and "&id={1}" is the id of the parent. It's a bit of a custom way and there are better ways to do it. This blog might help: http://www.robertgray.net.au/2011/5/27/creating-custom-multi-level-trees-in-umbraco.aspx
Multi-Level Custom Trees in 4.7
Hello!
I'm currently trying to create a custom tree and I'm running into trouble when trying to render a nodes children. After browsing various articles/posts I'm at this point:
The code above gets the article belonging to the current user (for the sake of testing, each user only has one article at the moment). I then attempt to print out the children of this article but instead of getting the desired output, I get the follwowing:
Article Name
- Article Name
- Article Name
- Article Name
Each time I expand a node, it just seems to render the same node, and goes on and on.
I've seen other ways of using the treeservice, like:
But I get an error saying there is no GetServiceUrl method that takes 0 arguments. I assume the method above was for earlier versions?
Any help would be greatly appreciated! Thanks
Here is the part of the code I used for creating a multi level custom tree. I hope it helps.
Jeroen
Hi Jeroen,
Thanks for your response.
Is the main part for rendering children this:
xNode.Source=string.Format(IOHelper.ResolveUrl(SystemDirectories.Umbraco)+"/tree.aspx?rnd={0}&id={1}&treeType={2}&contextMenu={3}&isDialog={4}&isProduct=true",Guid.NewGuid(), categoryEntity.CategoryId,TreeAlias,ShowContextMenu,IsDialog); Could you explain a bit more about this?Many Thanks,Yes xNode.Source is used to render children. When you try to open a child node "public override void Render(ref XmlTree tree)" is called again, but with different values. That's why I add "&isProduct=true" to the querystring and "&id={1}" is the id of the parent. It's a bit of a custom way and there are better ways to do it. This blog might help: http://www.robertgray.net.au/2011/5/27/creating-custom-multi-level-trees-in-umbraco.aspx
Jeroen
Hi Jeroen,
Thanks for that! Seems like it should do the trick. Im away from my computer for a few days then will give it a try!
Cheers,
is working on a reply...