Copied to clipboard

Flag this post as spam?

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


  • suzyb 474 posts 932 karma points
    Aug 19, 2013 @ 11:48
    suzyb
    0

    Nested templates MVC

    I'm currently working on my first umbraco site using MVC.  I'm trying to convert the templates for my news listing and news article pages.  Usually I would have the article be a child of the listing page so they could share certain content areas.

    I would normally have the following in my news listing template so I could overwrite the MainContent content with that of the individual article page.

    <asp:content ContentPlaceHolderId="MainContent" runat="server">
      <asp:ContentPlaceHolder Id="MainContent" runat="server">
        <umbraco:Macro Alias="NewsArticleList" runat="server" />
      </asp:ContentPlaceHolder>
    </asp:content>

    I can't see how to do something like this using MVC however.  I have tried using IsSectionDefined to set the article list to be default content but it doesn't seem to work.

    @if (IsSectionDefined("newsBody")) {
    @RenderSection("newsBody");
    }
    else { 
    @Umbraco.RenderMacro("NewsArticleList")
    }

    How do I specify default content to show if a child template doesn't have content for a section.

Please Sign in or register to post replies

Write your reply to:

Draft