Copied to clipboard

Flag this post as spam?

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


  • Huw Reddick 1734 posts 6073 karma points MVP c-trib
    Aug 05, 2021 @ 12:50
    Huw Reddick
    0

    'UmbNavItem' does not contain a definition for 'Content'

    Hi,

    I just installed the rc1 for this, however I am getting an error when trying to access the Content property of a UmbNavItem

    CS1061: 'UmbNavItem' does not contain a definition for 'Content'

  • Aaron 57 posts 405 karma points MVP c-trib
    Aug 05, 2021 @ 12:56
    Aaron
    0

    Hi Huw,

    Can you supply an example of what you are trying to do, I can then see if I can replicate / help with this.

    Also the Umbraco version (for example 8.x or 9)

  • Huw Reddick 1734 posts 6073 karma points MVP c-trib
    Aug 05, 2021 @ 13:32
    Huw Reddick
    0

    Hi Aaron,

    I have a very customised menu rendering in which I needto retreive various values from the navigation nodes in order to process them.

    So I need access to the IPublished Content of the menu nodes but don't seem to be able to.

    I need to do something like

    navitem.Content.HasProperty("disableDropdown")
    

    I realise I could accomplish some of this using the new properties on your nav item, but I didn't want to have to edit every item in the menu as these settings are already set on each of the content nodes.

  • Aaron 57 posts 405 karma points MVP c-trib
    Aug 05, 2021 @ 13:36
    Aaron
    0

    Thanks!

    Can you confirm the Umbraco version please

    Ok great I will take a look and get back to you.

  • Aaron 57 posts 405 karma points MVP c-trib
    Aug 05, 2021 @ 13:37
  • Huw Reddick 1734 posts 6073 karma points MVP c-trib
    Aug 05, 2021 @ 13:55
    Huw Reddick
    0

    Thanks for looking in to it

    I am using Umbraco 8.10.1

  • Aaron 57 posts 405 karma points MVP c-trib
    Aug 05, 2021 @ 14:09
    Aaron
    100

    Ok so I found the issue, the property somehow got removed during the move from MegaNavV8 to UmbNav.

    I have added it back, and a very quick test seemed to work.

    Please update to 1.0.0-rc.2 and the Content property should be back. https://www.nuget.org/packages/Our.Umbraco.UmbNav.Web/1.0.0-rc.2

    The code I used for testing:

    @foreach (var item in umbNav)
    {
        var hideChildren = false;
        if (item.ItemType == UmbNavItemType.Content && item.Content != null && item.Content.HasProperty("hideChildren"))
        {
            hideChildren = item.Content.Value<bool>("hideChildren");
        }
        <a class="nav-link @item.CustomClasses" href="@item.Url()" target="@item.Target" rel="@item.Noopener @item.Noreferrer">@item.Title</a>
        if (!hideChildren)
        {
            foreach (var child in item.Children)
            {
                <a class="nav-link @child.CustomClasses" href="@child.Url()" target="@child.Target" rel="@child.Noopener @child.Noreferrer">@child.Title</a>
            }
        }
    }
    

    Please let me know how you get on!

    If this solves your issue please mark this topic as solved, thanks!

  • Huw Reddick 1734 posts 6073 karma points MVP c-trib
    Aug 05, 2021 @ 15:12
    Huw Reddick
    0

    All working, many thanks for the quick fix

Please Sign in or register to post replies

Write your reply to:

Draft