Copied to clipboard

Flag this post as spam?

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


  • Ronak Panchal 71 posts 230 karma points
    Jul 09, 2016 @ 13:08
    Ronak Panchal
    0

    Helpers traverse throwing error at Level 11

    Hello all,

    I have following structure of node.

    Content

    ParentNode

    Node A
        Node 1
            Node 2
                Node 3
                    Node 4
                        Node 5  
                            Node 6
                                Node 7
                                    Node 8
                                        Node 9
                                            Node 10
                                                Node 11 (Multiple inner node)
    Node B
        Node 1
            Node 2
                .
                    .etc
    

    Now i have written below code (Using traverse) to display it in my page.

    @traverse(details)
    @helper traverse(dynamic node)
    {
        var items = node.Children;
        foreach (var item in items)
        {
           <a>item.Name</a>
        }
    
        @traverse(item)
     }
    

    The above code works only if the Parent node has children upto Level 10

    If i have Level 11, then i am getting below error: {Cannot evaluate expression because the current thread is in a stack overflow state.}

    Can anyone please help me out to display the above list in my page?

    Any suggestion would be appreciated.

  • Ian 178 posts 752 karma points
    Jul 09, 2016 @ 13:18
    Ian
    0

    Might sound like a terse comment but is the no way at all you can re-evaluate your node structure theres an aweful lot of nesting there (just me but i thought too much) if you can explain the object acheived by your current approach we could suggest a different way. Just trying to be helpful ;) disregard if you like.

  • Ronak Panchal 71 posts 230 karma points
    Jul 09, 2016 @ 18:36
    Ronak Panchal
    0

    Hello lan

    Thanks for your quick reply

    Scenario is that i have one document type is for question. second document type is for answer.after that i allow answer document type below question and answer too. now i create one question it have multiple reply and reply of reply.

    • Question(parent Document type)
      • reply 1(child Document type)
        • reply 1.1(child Document type)
          • reply 1.1.1(child Document type)
            • Up to n level reply of reply (child Document type)
      • reply 2(child Document type)
        • reply 2.1(child Document type)
          • reply 2.1.1(child Document type)
            • Up to n level reply of reply (child Document type)

    now i need to display

    reply 1

    reply 1.1

    reply1.1.1

    up-to n levels

    reply 2

    reply 2.1

    reply 2.1.1

    up-to n levels

    for that i use umbraco helper but it gives me upto 11 levels after that it gives an error as mansion in question .

    is there any way to get the n level of nodes.

    Thanks.

  • Ian 178 posts 752 karma points
    Jul 09, 2016 @ 19:11
    Ian
    0

    Thanks for your explanation can i ask in simple terms what sort of system is it you are devising? FAQ? forum? Interview transcript? Just trying to get my head round this and it helps to know the big picture

  • Ronak Panchal 71 posts 230 karma points
    Jul 09, 2016 @ 19:20
    Ronak Panchal
    0

    I'm devising a system bit like a Forum type. Thanks.

  • Ian 178 posts 752 karma points
    Jul 09, 2016 @ 19:58
    Ian
    0

    If you want to display things in a hierarchy then you will need to use the children method however your code illustration just shows a flat list of links in which case you could use 'descendants' instead how many levels are in the item causing the error? What happens if you put a breakpoint on the loop and step through looking closely at the state of 'item' at level 10 and 11. I don't know if you need to put some checks in to see if item has children before trying to iterate. For one reason or an other you are running out of memory often caused by an infinite recursion but i don't know if that is possible in your case.

    I would also say you are using dynamic published content rather than typed content which is easier when it comes to accessing properties but if you are looping through a lot of content then there may be a lot of properties there you dont need taking memory when you can just access those you want on typed content with GetPropertyValue('propertyalias') I believe though the performance overhead is normally supposed to be minimal so it may not make a difference.

  • Nik 1593 posts 7151 karma points MVP 6x c-trib
    Jul 10, 2016 @ 13:57
    Nik
    1

    I would consider using something more like relationships than a fully structured tree as you are currently configuring it. If you work on the tree approach you will most likely always find a stack overflow limit due to the nature of dynamically evaluating an expression like that.

    In addition, I would consider not using Umbraco content nodes for each response. Each response would result in a republish of the site cache, an in turn result on a massive cached XML file on disk.

Please Sign in or register to post replies

Write your reply to:

Draft