Copied to clipboard

Flag this post as spam?

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


  • a 8 posts 88 karma points
    Aug 06, 2021 @ 16:09
    a
    0

    Creating a menu system in Umbraco 9

    Previously when creating a Navigation partial I was able to use this type of syntax.

    @inherits Umbraco.Web.Mvc.UmbracoViewPage

    @{ var homePage = Model.AncestorOrSelf

    Also could use and then all I had to do was loop through

    @foreach (var page in Model.AncestorOrSelf(1).Children.Where(x => x.IsVisible()))

    I am now attempting this in Umbraco 9 and all I get is this un helpful error

    enter image description here

    'ViewsPartials__Navigation' does not contain a definition for 'AncestorOrSelf' and the best extension method overload 'PublishedContentExtensions.AncestorOrSelf

    Could anybody enlighten me please.

    Thanks in advance.

  • Bjarke Berg 29 posts 265 karma points hq
    Aug 06, 2021 @ 16:13
    Bjarke Berg
    0

    It sounds like you do not have a using of

    Umbraco.Extensions
    

    In the view or the _ViewImports.cshtml

  • a 8 posts 88 karma points
    Aug 09, 2021 @ 08:45
    a
    0

    Hello, thank you for replying. Both _ViewImports and my partial have the @using Umbraco.Extensions;

    Maybe I am missing something in the appsettings.json file? I am fairly new to CMS Umbraco so even the IPublished is a bit confusing.

Please Sign in or register to post replies

Write your reply to:

Draft