Copied to clipboard

Flag this post as spam?

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


  • nickornotto 317 posts 679 karma points
    May 13, 2013 @ 18:35
    nickornotto
    0

    custom section tree item name duplicated

    Hi,

    I have created a new section in Umbraco back office where I created a folder with 2 nodes - each going to a different page:

    * First Page

    * Second Page

    I created these based on the tutorial here: http://www.nibble.be/?p=71 and here: http://abrissirba.wordpress.com/2012/12/09/custom-section-in-umbraco-back-office/

    Basically in RenderJS I append 2 above pages to display in the left hand side tree of my section.

    They firstly display fine then when I go somewhere else in the CMS and go back to the section the page names on each link are dupliacted, eg:

    * First PageSecond Page

    * First PageSecond Page

    When I go again and come back to the section they are further duplicated, eg:

    * First PageSecond PageFirst PageSecond Page

    * First PageSecond PageFirst PageSecond Page

    The script is clearly adding the names instead of replacing them each time but I don't know what to change to fix it.

    Anyone has idea what I shall do? Thanks

     

    here is my code:

     

    namespace MyRequests.Trees
    {
        public class LoadCustomTree : BaseTree
        {
            public LoadCustomTree(string application) : base(application) { }


            protected override void CreateRootNode(ref XmlTreeNode rootNode)
            {
                rootNode.Icon = FolderIcon;
                rootNode.OpenIcon = FolderIconOpen;
                rootNode.NodeType = "init" + TreeAlias;
                rootNode.NodeID = "init";

            }

            protected override void CreateRootNodeActions(ref List<IAction> actions)
            {
                actions.Clear();
                actions.Add(ActionNew.Instance);
                actions.Add(ActionRefresh.Instance);
            }

            protected override void CreateAllowedActions(ref List<IAction> actions)
            {
                actions.Clear();
                //actions.Add(ActionRefresh.Instance);
                actions.Add(ActionDelete.Instance);
                
            }

            public override void Render(ref XmlTree tree)
            {

                XmlTreeNode nodeRequests = XmlTreeNode.Create(this);
                            nodeRequests.NodeID = "1";
                            nodeRequests.Text = "Policy Requests";
                            nodeRequests.Action = "javascript:openRequests('" + "1" + "');";
                            nodeRequests.Icon = "doc.gif";
                            tree.Add(nodeRequests);

                            XmlTreeNode nodeFunds = XmlTreeNode.Create(this);
                            nodeFunds.NodeID = "1";
                            nodeFunds.Text = "Funds Upload";
                            nodeFunds.Action = "javascript:openFunds('" + "1" + "');";
                            nodeFunds.Icon = "doc.gif";
                            tree.Add(nodeFunds);

            }

                    public override void RenderJS(ref StringBuilder Javascript)
                    {
                        Javascript.Append(
                             @"
                        function openRequests(id) {
                            parent.right.document.location.href = 'RM/editRMRequests.aspx?id=' + id;
                        }
                    ");
                        Javascript.Append(
                             @"
                        function openFunds(id) {
                            parent.right.document.location.href = 'RM/editRMPage.aspx?id=' + id;
                        }
                    ");
                    }
        }
    }

     

  • Jan Skovgaard 11258 posts 23500 karma points MVP 7x admin c-trib
    May 13, 2013 @ 21:01
    Jan Skovgaard
    0

    Hi Eva

    Could you post a screendump of what it looks like in the Umbraco backoffice? And what version of Umbraco are you using?

    /Jan

  • Tom Fulton 2030 posts 4996 karma points c-trib
    May 13, 2013 @ 21:02
    Tom Fulton
    0

    Also, try making sure each of your tree nodes has a unique ID (I notice you assign '1' in both nodes above).

  • nickornotto 317 posts 679 karma points
    May 14, 2013 @ 10:06
    nickornotto
    0

    The id doesn't matter as it is not caught in aspx scripts.

    Here are the screenshots:

    Correct view - this displays only when first time in the section after login

     

    Second view after coming back to the section

     

    Third view after coming back to the section again

  • nickornotto 317 posts 679 karma points
    May 21, 2013 @ 15:53
    nickornotto
    0

    Any ideas on this? Still cannot make it working properly :(

  • nickornotto 317 posts 679 karma points
    May 21, 2013 @ 17:07
    nickornotto
    0

    Resolved :)

    I had set

    nodeFunds.NodeID="1";

    for all tree nodes, each has to have different id of course

  • Tom Fulton 2030 posts 4996 karma points c-trib
    May 21, 2013 @ 17:20
    Tom Fulton
    0

    You got it - you do need to set the Node ID for each node to avoid this, otherwise I think there's some ID/Class conflicts causing this issue.  Glad that worked!

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies