Copied to clipboard

Flag this post as spam?

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


  • Sharmarke Hujale 103 posts 346 karma points
    Dec 01, 2015 @ 21:07
    Sharmarke Hujale
    0

    Problem with child pages (navigation)

    Hey guys!

    I've created an About Us page - underneath it I've created some child pages:

    enter image description here

    This is how it looks:

    enter image description here

    This is the razor I use:

    @if (CurrentPage.Children.Where("Visible").Any())
    {
    <ul>
        @* For each child page under the root node, where the property umbracoNaviHide is not True *@
        @foreach (var childPage in CurrentPage.Children.Where("Visible"))
        {
            <li>
                <a href="@childPage.Url">@childPage.Name</a>
            </li>
        }
    </ul>
    

    }

    But the problem is, when I click on the child pages, for example the "our area of work" - its pages navigation is not there anymore.

    And know that, because the child page, doesn't have any child pages.

    But can someone help me out with this? I need it to be fixed!

    Thanks in advance!

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Dec 01, 2015 @ 21:25
    Dennis Aaen
    100

    Hi Sharmarke,

    Dependig on your content structure, this should do the trick for you. Perhaps you need to change the AncestorOrSelf(2).

    @if (CurrentPage.AncestorOrSelf(2).Children.Where("Visible").Any())
    {
    <ul>
        @* For each child page under the root node, where the property umbracoNaviHide is not True *@
        @foreach (var childPage in CurrentPage.AncestorOrSelf(2Children.Where("Visible"))
        {
            <li>
                <a href="@childPage.Url">@childPage.Name</a>
            </li>
        }
    </ul>
    }
    

    Hope this can help you in the right direction.

    /Dennis

  • Sharmarke Hujale 103 posts 346 karma points
    Dec 01, 2015 @ 22:25
    Sharmarke Hujale
    0

    Thanks Dennis!

    It's working now.

Please Sign in or register to post replies

Write your reply to:

Draft