Copied to clipboard

Flag this post as spam?

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


  • Asger 25 posts 171 karma points
    Jun 10, 2016 @ 14:24
    Asger
    0

    Automatic menu for children of subpage.

    Hi Guys.

    First of all, thanks for this awesome community. I have a little issue, that i hope you can solve for me.

    I am using the razer syntax menu like this:

    @{ var selection = CurrentPage.AncestorOrSelf(2).Children;}

    What i want to do, is to choose a specific sup page, and write out the menu with only the children of that sub page.

    I hope someone can help.

    Have a nice weekend!

  • Alex Skrypnyk 6163 posts 24143 karma points MVP 8x admin c-trib
    Jun 10, 2016 @ 14:39
    Alex Skrypnyk
    100

    Hi Asger,

    For that issue you can use Content Picker property editor in backend - just for selecting needed node.

    In Razor you need to iterate over child nodes of selected node.

    var selectedNode = Umbraco.TypedContent('selectedId');
    foreach (var childNode in selectedNode.Children)
    {
        <li>
            <a href="@childNode.Url">@childNode.Name</a>
        </li>
    }
    

    Cheers, Alex

  • Asger 25 posts 171 karma points
    Jun 15, 2016 @ 10:00
    Asger
    0

    Hi Alex.

    I had some problems, but i ended up solving it like this:

      @{
        var page = Umbraco.TypedContent(1095);
    }
    
    @foreach (var child in page.Children) { 
        <li>
             <a href="@child.Url">@child.Name</a>
        </li><br/>
    }
    

    Thank you for the help :)

  • Alex Skrypnyk 6163 posts 24143 karma points MVP 8x admin c-trib
    Jun 23, 2016 @ 21:35
    Alex Skrypnyk
    0

    asger storebjerg, you are welcome!

Please Sign in or register to post replies

Write your reply to:

Draft