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:
public override void Render(ref XmlTree tree)
{
List<Node> articles = NodeUtil.GetAllNodesOfDocumentType(-1, "Promoter");
Node article = articles.Where(p => p.CreatorID == UmbracoEnsuredPage.CurrentUser.Id).FirstOrDefault();
if(promo != null)
{
var dNode = XmlTreeNode.Create(this);
dNode.NodeID = article.Id.ToString();
dNode.Text = article.Name;
dNode.Icon = "doc.gif";
dNode.Action = "javascript:openArticle(" + article.Id + ")";
dNode.Source = article.Children.Count > 0 ? this.GetTreeServiceUrl("" + article.Id) : "";
tree.Add(dNode);
}
}
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:
TreeService treeService = new TreeService(...);
node.Source = treeService.GetServiceUrl();
But I get an error saying there is no GetServiceUrl method that takes 0 arguments. I assume the method above was for earlier versions?
It took me a while to work this out. Here is the solution, hope it would help someone.