Copied to clipboard

Flag this post as spam?

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


  • bh 444 posts 1544 karma points
    Mar 09, 2021 @ 14:29
    bh
    0

    NestedContent inside NestedContent

    I have a page view Home.cshtml

    @foreach(var item in Model.Value<IEnumerable<IPublishedElement>>("retailContent")) {
         @Html.Partial($"Nested Content/ncHomeRetail", item)  
    }
    

    I have a nestedcontent view ncHomeRetail.cshtml

    @foreach(var btn in Model.Value<IEnumerable<IPublishedElement>>("button")) { 
                @Html.Partial($"Nested Content/ncButton", btn)                           
    }
    

    I have a nested content view ncButton.cshtml

    @if(Model.HasValue("link") && Model.HasValue("text")) { 
        bool newWindow = Model.Value("openInAnewWindow") == null ? false : Model.Value<bool>("openInAnewWindow");
        <a href="@Model.Value("link")" target="@newWindow" class="btn">@Model.Value("text")</a>
    }
    

    I have 2 ncHomeRetail items on the home page. Problem is, it's displaying the ncButton for the first ncHomeRetail item on both ncHomeRetail items.

    Everything else on ncHomeRetail displays the correct value. Just not the button piece.

    What am I missing?

  • bh 444 posts 1544 karma points
    Mar 11, 2021 @ 13:33
    bh
    0

    Bump

Please Sign in or register to post replies

Write your reply to:

Draft