Copied to clipboard

Flag this post as spam?

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


  • Jon 47 posts 290 karma points
    Aug 17, 2016 @ 09:55
    Jon
    0

    Navigation - Subpages / children - Macro

    How do I get the next level (subpages / children) of each page?

    @{
        var root = CurrentPage.AncestorOrSelf(2);
    }
    
    <ol>
        <li><a href="/"><img src="~/img/home.svg"></a></li>
        @foreach (var page in root.Children.Where("Visible"))
    
    
        {
    
            <li class="@(page.IsAncestorOrSelf(CurrentPage) ? "current" : null)">
                <a href="@page.Url">@page.Name</a>
    
            </li>
        }
    </ol>
    
  • Jon 47 posts 290 karma points
    Aug 17, 2016 @ 09:59
    Jon
    100

    Solved it :-)

    @foreach (var subpage in page.Children.Where("Visible")) {
    
        <li><a href="">@subpage.Name</li>
    
    }
    
Please Sign in or register to post replies

Write your reply to:

Draft