Copied to clipboard

Flag this post as spam?

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


  • glenatron 37 posts 132 karma points
    Apr 06, 2014 @ 18:25
    glenatron
    0

    Problem with displaying a content tree in custom 6.1.6 panel

    I am creating a new section to display some custom statistics for my site and I am running into some problems with how to display the currently open part of the tree ( in a custom tree class that extends BaseTree )

    It seems as though if I don't display the children of my root node, I don't get to see any child nodes ever. If I do display the children, I can see all of them in a single flat list, regardless of whether or not I have opened them.

    I can't seem to find much about how to implement this stuff in the forums or documentation so I'm feeling a little bit lost here- this is what I currently have:

        private XmlTree RenderNode( XmlTree tree, IPublishedContent content )
        {
            var currentNode= XmlTreeNode.Create(this);
            currentNode.Icon = "statistics.png";
            currentNode.Text = content.Name;
            currentNode.NodeID = content.Id.ToString();
    
            currentNode.Action = (0 < content.Children.Count()) ? this.GetTreeServiceUrl(content.Id) : ""; //String.Format("javascript:showChildNodes({0});", content.Id);
            currentNode.Menu.Clear();
            currentNode.Menu.Add(new ShowStatsAction());
            tree.Add(currentNode);
    
    
            return tree;
        }
    
        public override void Render(ref XmlTree tree)
        {
            if (this.id < 0)
            {
                this.id = help.TypedContentAtRoot().First().Id;
            }
            var node = help.TypedContent(this.id);
            tree = RenderNode(tree, node);
            if (0 < node.Children.Count())
            {
                foreach (IPublishedContent child in node.Children)
                {
                    tree = RenderNode(tree, child);
                }
            }
    
        }
    

    I realise it's pretty untidy because I'm currently wrangling it around to figure out what is going on.

    My question is basically what do I need to do to render only the nodes up to the current one in the same configuration as you would get on the Content Admin page?

    Also having the node url on Action property is probably wrong, so I guess this may be why nothing is happening when I click on the Home node in the case where it isn't automatically displaying all child nodes. How can I set the action on a node to "Open child nodes"

Please Sign in or register to post replies

Write your reply to:

Draft