Copied to clipboard

Flag this post as spam?

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


  • Ali Sheikh Taheri 470 posts 1648 karma points c-trib
    Aug 04, 2010 @ 16:41
    Ali Sheikh Taheri
    0

    how to get node level in c#?

    is there any way that I can get the level of a node in c#?

    basically I want to get the parent node of a node that has the level 2.

    here is the site structure:

    -site

    -----news

    ------------2010

    ----------------08

    ---------------------- article 1

    ----- FAQ

    ---------- faq items

    I know I can use this : 

    Node currentNodeRoot = Node.GetCurrent().Parent.Parent.Parent;

    but I want the above code to be dynamic and as you can see FAQ the above code is not working with FAQ because of the structure.

    Any thought ?

    Cheers

    Ali

  • Sebastiaan Janssen 5060 posts 15522 karma points MVP admin hq
    Aug 04, 2010 @ 16:53
    Sebastiaan Janssen
    0

    Have a look at this topic, it should be helpful.

  • Ali Sheikh Taheri 470 posts 1648 karma points c-trib
    Aug 04, 2010 @ 16:57
    Ali Sheikh Taheri
    0

    Thanks for your post. - your 1000th post:) 

    What class shall I extend to be able to do that?

    Cheers

    Ali

  • Matt Brailsford 4125 posts 22223 karma points MVP 9x c-trib
    Aug 04, 2010 @ 16:59
    Matt Brailsford
    1

    Hey Ali,

    I'd also check here, includes code samples

    http://our.umbraco.org/forum/developers/api-questions/11190-Level-property-from-Node

    Matt

  • Ali Sheikh Taheri 470 posts 1648 karma points c-trib
    Aug 04, 2010 @ 17:28
    Ali Sheikh Taheri
    0

    thanks matt,

    I am going to use this wicked code:

    umbraco.presentation.nodeFactory.Node.GetCurrent().Path.Split(',').Length

    Cheers Matt

    Ali

Please Sign in or register to post replies

Write your reply to:

Draft