Copied to clipboard

Flag this post as spam?

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

  • Matt 322 posts 754 karma points
    Jan 25, 2022 @ 11:20

    Code not working on Umbraco 9

    Hi all,

    I had this navigation partial view working in Umbraco8, but doesnt seem to work on Umbraco 9

    @inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage
    @using Umbraco.Cms.Core
    @using Umbraco.Cms.Core.Models.PublishedContent
    @using Umbraco.Cms.Core.Routing
    @using Umbraco.Extensions
    @inject IPublishedValueFallback PublishedValueFallback
    @inject IPublishedUrlProvider PublishedUrlProvider
        var selection = Umbraco.ContentAtRoot().FirstOrDefault()
        .Where(x => x.IsVisible());
    <div data-collapse="medium" data-animation="default" data-duration="400" class="navbar w-nav">
        <nav role="navigation" class="nav-menu w-nav-menu">
            <a href="/" class="link-block w-inline-block w--current"><img src="~/images/home_1home.png" alt="Home"></a>
            @foreach (var item in selection)
                var children = item.Children(c => c.IsVisible()).ToArray();
                if (!item.Value<bool>("disableDropdown") && (children.Any()))
                    <div data-hover="1" data-delay="0" class="dropdown-link w-dropdown">
                        <div class="dropdown-toggle w-dropdown-toggle">
                            <div class="testt">@item.Name</div>
                        <nav class="w-dropdown-list">
                            @foreach (var child in children)
                                <a href="@child.Url" class="nav-link w-dropdown-link">@child.Name</a>
                    <a href="@item.Url" class="nav-link w-nav-link">@item.Name</a>
        <div data-ix="triangle-nav" class="triangle-nav-button w-nav-button">
            <div class="triangle"></div>

    But Im getting the following error when trying to use it in umbraco 9?

    enter image description here

  • Patrick de Mooij 55 posts 468 karma points MVP 2x c-trib
    Jan 25, 2022 @ 12:16
    Patrick de Mooij

    Hi Matt,

    De .Url variable doesn't exists anymore in v9. You now have to use the method .Url()

Please Sign in or register to post replies

Write your reply to: