Copied to clipboard

Flag this post as spam?

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


  • Christian Koch 20 posts 90 karma points
    May 25, 2019 @ 23:04
    Christian Koch
    0

    Bug in partial view snippet for navigation

    The snippet for navigation in U8 is generated as followed

    @inherits Umbraco.Web.Mvc.UmbracoViewPage
    @using Umbraco.Web
    
    
    @*
        This snippet displays a list of links of the pages immediately under the top-most page in the content tree.
        This is the home page for a standard website.
        It also highlights the current active page/section in the navigation with the CSS class "current".
    *@
    
    @{ var selection = Model.Root().Children.Where(x => x.IsVisible()).ToArray(); }
    
    @if (selection.Length > 0)
    {
        <ul>
            @foreach (var item in selection)
            {
                <li class="@(item.IsAncestorOrSelf(Model.Content) ? "current" : null)">
                    <a href="@item.Url">@item.Name</a>
                </li>
            }
        </ul>
    }
    

    Here seems to be a bug. In Umbraco 8 the RenderModel has been removed, so it is no longer Model.Content just Model.

            <li class="@(item.IsAncestorOrSelf(Model.Content) ? "current" : null)">
    

    Therefore correct should be

            <li class="@(item.IsAncestorOrSelf(Model) ? "current" : null)">
    

    Am I right?

  • Søren Kottal 702 posts 4497 karma points MVP 5x c-trib
    May 30, 2019 @ 12:52
    Søren Kottal
    0

    Hi Christian

    Yes, Model is the equivalent of Model.Content fro v7s UmbracoTemplatePage :)

Please Sign in or register to post replies

Write your reply to:

Draft