Copied to clipboard

Flag this post as spam?

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


  • Wesley 8 posts 78 karma points
    Sep 07, 2023 @ 12:09
    Wesley
    0

    UmbNav: Includes Child Pages

    I want to create a custom menu for a website and the best way for a editor is UmbNav in our opinion. It works like a charm for the editor but I've got one question about the 'Includes Chid Pages' option.

    When selected the menu shows the child items as expected but when there's another level it won't show. Is this not possible and is this check only for 1 level deeper or do I need to do something else?

    When manually building the menu it works like it should with the 3 levels. The code is a 'work in progress' and need to be optimized where possible.

    <ul>
    @foreach (var child in item.Children.Where(c => c.Content != null))
    {
        if (child.Children != null && child.Children.Any())
        {
            <li class="has-children">
                <input type="checkbox" id="@child.Key" />
                <a href="@child.Content.Url()" class="@child.CustomClasses @Html.If(@child.IsActive, "active")" target="@child.Target">
                    <span>@Html.Coalesce(child.Title, child.Name)</span>
                </a>
                <label for="@child.Key"></label>
                <ul>
                    @foreach (var subChild in child.Children.Where(s => s.Content != null))
                    {
                        <li>
                            <a href="@subChild.Content.Url()" class="@subChild.CustomClasses @Html.If(@subChild.IsActive, "active")" target="@subChild.Target">
                                <span>@Html.Coalesce(subChild.Title, subChild.Name)</span>
                            </a>
                        </li>
                    }
                </ul>
            </li>
        }
        else
        {
            <li>
                <a href="@child.Content.Url()" class="@child.CustomClasses @Html.If(@child.IsActive, "active")" target="@child.Target">
                    <span>@Html.Coalesce(child.Title, child.Name)</span>
                </a>
            </li>
        }
    }
    

  • Huw Reddick 1929 posts 6697 karma points MVP 2x c-trib
    Sep 07, 2023 @ 13:02
    Huw Reddick
    0

    Yes, it is only checking one level down, i.e. the children of the UmbNav item, so if your children also have children you will need to construct your own view

  • Wesley 8 posts 78 karma points
    Sep 15, 2023 @ 06:42
    Wesley
    0

    Thanks for your clarifaction and I'll construct my own view then!

Please Sign in or register to post replies

Write your reply to:

Draft