Copied to clipboard

Flag this post as spam?

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


  • Mike Manusama 45 posts 195 karma points
    Sep 29, 2016 @ 19:48
    Mike Manusama
    0

    Nested @RenderBody() question

    I am having an issue in my template where I am getting 2 errors thrown no matter what I do. My following template structure is

    -Base (header, footer, scripts) --BaseInterior (global interior page template that collects user inputted page title and page intro) ---InteriorPageContent ( I have a ton of these that is bringing in page specific content under the pages title and intro)

    In my Base file, which is my master I obviously have RenderBody(). In my interior pages (BaseInterior), I have something like this:

    <div class="page-interior">
        <div class="container">
            <div class="row">
                <div class="col-xs-12">
                    <h1>@Umbraco.Field("pageTitle")</h1>
    
                    @Umbraco.Field("pageIntro")
                </div>
            </div>
        </div>
        @CurrentPage.GetGridHtml("pageGrid")
    
        @RenderBody()
    </div>
    

    Ideally the InteriorPageContent would chain its way up to base and output everything on the page. I have read that nesting the RenderBody() is an issue, but here is my experience. I have an InteriorPageContent template that in fact shows its content as well as PageInterior and Base just fine. There is another page, however, thats content is created within the Umbraco Grid. That page is throwing the error

    "The file "~/Views/BaseInterior.cshtml" cannot be requested directly because it calls the "RenderBody" method."

    When I take out the RenderBody() from BaseInterior that page works, but then the page that worked beforehand is throwing me this error:

    The "RenderBody" method has not been called for layout page "~/Views/BaseInterior.cshtml".

    It seems like I can't have my cake and eat it too and I am wondering what the issue might be that is causing this mess? Do I need to create one page template for pages that will be using a grid and one for those that will have anther template nested under it?

  • Alex Skrypnyk 6132 posts 23951 karma points MVP 7x admin c-trib
    Oct 06, 2016 @ 14:11
    Alex Skrypnyk
    0

    Hi Mike,

    Thank you, very nice post.

    Can you use Html.Partial in the BaseInterior.cshtml for rendering InteriorPageContent view?

    Thanks,

    Alex

  • Alex Skrypnyk 6132 posts 23951 karma points MVP 7x admin c-trib
    Oct 10, 2016 @ 16:01
    Alex Skrypnyk
    0

    Hi Mike,

    Did you solve the problem?

    Can you share with us?

    /Alex

Please Sign in or register to post replies

Write your reply to:

Draft