Copied to clipboard

Flag this post as spam?

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


  • Umbraco Beginner 10 posts 110 karma points
    Sep 20, 2019 @ 17:14
    Umbraco Beginner
    0

    Nested Content Rendering from a parent page

    Hello Experts,

    Document Structure

    I have a nested content editor with a document type that has a two text string fields and one repeatable textstring field.

    The document type that has a nested content editor is a child of another document type.

    My Question

    How do I render the nested content type in a parent document type template?

    Here is where I am

    @foreach (ContentModels.DTWithNestedEditor _document in Model.Content.Children)
    {
        @_document .Name  
    
       //Display nested component values
            //Single textstring
           //Repeatable teststring
    
    }
    
  • Nik 1599 posts 7179 karma points MVP 6x c-trib
    Sep 20, 2019 @ 17:41
    Nik
    100

    Hi Umbraco Beginner

    You could do something like this:

    @foreach(ContentModels.DTWithNestedEditor _document in Model.Content.Children)
    {
           @_document.Name
           if(_document.NestedContentProperty != null)
           {
                foreach(NestedContentType nestedContentType in _document.NestedContentProperty)
                 {
                            <div>@nestedContentType.StringProperty1</div>
                            <div>@nestedContentType.StringProperty2</div>
                            @foreach(var stringVal in nestedContentType.RepeatedStringProperty)
                            {
                                          <div>@stringVal</div>
                            }
                 }
           }
    }
    

    Give that ago and see if it works for you :-)

    Nik

  • Umbraco Beginner 10 posts 110 karma points
    Sep 20, 2019 @ 17:43
    Umbraco Beginner
    0

    Thanks. It works

Please Sign in or register to post replies

Write your reply to:

Draft