Copied to clipboard

Flag this post as spam?

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


  • Burns 4 posts 74 karma points
    Mar 18, 2016 @ 10:10
    Burns
    0

    RenderSection in foreachLoop

    Hi,

    first of all - i´m new in Umbraco but i learned a lot in the last 2 Month. I want to use the RenderSection Methode in a foreach Loop.

    In my Templates every Template have this Section defined.

    This is my error: The following sections have been defined but have not been rendered for the layout page "~/Views/Master.cshtml": "content_section".

    this is myCode: @helper GetNodes(){

                var nodes = CurrentPage.Site().Children.Where("Visible && DocumentTypeAlias != @0","pageContainer").ToList();
                foreach (var childNode in nodes)
                {
    
                      @childNode.Id 
                      @RenderSection("content_section",false)
                      @childNode.Name
                }
    
            }
    

    is there a work around ? Thanks for help

  • Dennis Adolfi 1082 posts 6449 karma points MVP 6x c-trib
    Mar 18, 2016 @ 11:00
    Dennis Adolfi
    0

    Im not really sure what you want to accomplish or if you really want to use partials, but:

    The @RenderSection("content_section", false) should only be referenced once, in you master template (thats what the error message says) and when you want to put content in that section, you write:

    @section content_section{
       // Content goes here.
    }
    
  • Burns 4 posts 74 karma points
    Mar 18, 2016 @ 12:28
    Burns
    0

    Hi Dennis, thank you for your answer

    in each different template i have different design
    SubTemplate 1 < section class="sec1">design1 < /section>
    SubTemplate 2 < section class="sec2">design2< /section>
    SubTemplate 3 < section class="sec3">design3< /section>
    .......

    in Master Template i have Navigation, Header and footer. I want that i could put different sortable sections, with different design and content in the body like:

    < html>< header>< nav>ss< /header>
    < section class="sec2">Content< /section>
    < section class="sec3">Content< /section>
    < section class="sec1">Content< /section>
    < section class="sec3">Content< /section>
    < section class="sec1">Content< /section>
    ....
    < footer>< /footer> < /html>

  • Dennis Adolfi 1082 posts 6449 karma points MVP 6x c-trib
    Mar 18, 2016 @ 13:09
    Dennis Adolfi
    0

    Ok, so did my suggestion work for you?

  • Burns 4 posts 74 karma points
    Mar 18, 2016 @ 14:52
    Burns
    0

    sorry no - because i already implent this sectiob

Please Sign in or register to post replies

Write your reply to:

Draft