Copied to clipboard

Flag this post as spam?

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


  • Thomas 43 posts 123 karma points
    Aug 06, 2018 @ 09:43
    Thomas
    0

    How to check the umbraco content page has how many parent/childs?

    How to find the umbraco content page has how many parent (like parent, parent of parent) / child ?

    example some content page has two parent to reach the site root but some content page has three parent to reach the site root. so how to find and follow this? and how to differentiate it

  • Louis Ferreira 69 posts 266 karma points
    Aug 07, 2018 @ 08:23
    Louis Ferreira
    0

    Hi Thomas,

    You could use the

    @Model.Ancestors()
    

    property which returns a collection of all the current pages parents. To see how far away they are up the tree from the current page, you could check the Level property

    @foreach (IPublishedContent parent in Model.Ancestors() {
    <span>@parent.Level</span>
    }
    

    Hope that helps

    Louis

Please Sign in or register to post replies

Write your reply to:

Draft