Copied to clipboard

Flag this post as spam?

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


  • Rizwan 28 posts 138 karma points
    Aug 22, 2022 @ 05:38
    Rizwan
    0

    Navigation from site settings root node

    Dear Experts. I have a document type called site settings in root node. site settings has nested content with single multiurl picker and title and multiurl picker for child pages. in my partial view i am able to access the node site settings and nested content properties which shows data i added. when i try to access the properties i cant able to get the data.

     @inherits UmbracoViewPage
    @using Umbraco.Cms.Core.Models;
    @using Umbraco.Cms.Web.Common.PublishedModels;
    @using ContentModels = Umbraco.Cms.Web.Common.PublishedModels;
    @{
        var siteSettings = Umbraco.ContentAtRoot().FirstOrDefault(x => x.ContentType.Alias == "siteSettings");
        var navigationItems = siteSettings.Value<IEnumerable<IPublishedElement>>("mainNavigation");
    
    
    }
    @if(navigationItems!=null && navigationItems.Any())
    {
        <ul class="nav nav-pills" id="mainNav">
            @foreach(var item in navigationItems)
            {
    
                var hasChildLinks = item.ChildLinks;//unable to access childlinks property
    
    
            }
        </ul>
    }
    
  • Huw Reddick 1749 posts 6114 karma points MVP c-trib
    Aug 23, 2022 @ 13:34
    Huw Reddick
    0

    you need to do something like below

    var hasChildLinks = item.Value<T>("childLinks");
    
Please Sign in or register to post replies

Write your reply to:

Draft