Copied to clipboard

Flag this post as spam?

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


  • Martin 18 posts 73 karma points
    Mar 08, 2011 @ 10:42
    Martin
    0

    Nested Templates

    i have a mainpage that takes in 3 different layouts, depending on kind of page, and in each of those layouts, there is a menue, a main area, and a right column.

     

    is it not possible to nest content areas inside another content area with regular html code around?

  • Hendy Racher 863 posts 3849 karma points MVP 2x admin c-trib
    Mar 08, 2011 @ 10:54
    Hendy Racher
    0

    Hi Martin,

    Yes you can use nested Templates (aka nested MasterPages) - once you've created your top level template, insert content area placeholders where you'd like the nested templates to render their markup, (there's a button in the back office to do this, and it will add standard ASP.NET ContentPlaceHolders)

    <asp:ContentPlaceHolder Id="bodyContentPlaceHolder" runat="server" />

    To create your nested templates, right click on the parent template in the tree, and select Create, Umbraco will automatically populate the child templates with the appropate content area tags (standard ASP.NET Content tags):

    <asp:Content ContentPlaceHolderID="bodyContentPlaceHolder" runat="server">
    ...
    </asp:Content>

    HTH,

    Hendy

  • Martin 18 posts 73 karma points
    Mar 08, 2011 @ 11:09
    Martin
    0

    Hi and Thanks for that Hendy, however

    what i meant with nested is that i want several Content areas inside another content area.

    for example in my mainpage i want to throw in 3 different templates depending on what design is needed

    and in each of those templates, which then has a main Content placeholder with all the markup AND inside that

    there is Content placeholder for a menue, and a Content placeholder for main area, and a content placeholder for right column and so on.

    All that is inside the main Content area for that design, which in turn is injected into the main template.

    and it doesnt seem to work!

  • Ove Andersen 435 posts 1541 karma points c-trib
    Mar 08, 2011 @ 11:17
    Ove Andersen
    0

    Can you post an excerpt of your masterpages?

  • Martin 18 posts 73 karma points
    Mar 08, 2011 @ 11:42
    Martin
    0

    Certainly!

    <!-- BEGIN LAYOUT -->

     

    <

     

    asp:ContentPlaceHolder ID="layout" runat="server" />

     

    <!-- END LAYOUT -->

    That is what the toplevel master contains right..it has a header, footer, and all other html tags.

    now..layout in turn contains.

    <%

    @ Master Language="C#" MasterPageFile="~/masterpages/Master1.master" AutoEventWireup="true" %>

    <

     

    asp:Content ContentPlaceHolderID="layout" runat=server>

     

    <div id="content">

     

    <div class="breadcrumb">

     

    <umbraco:Macro Alias="BreadCrumbs" runat="server"></umbraco:Macro>

     

    </div>

     

    <div class="printthingy">

     

    <a class="printpage" href="#" onclick="print(); return false;" title="Skriv ut denna sida">Skriv ut</a>

     

    </div>

     

    <div class="clearfloat"></div>

     

    <div class="leftcontainer">

     

    <!-- FIX MENUE -->

     

    <div class="menu" id="menu">

     

    <ul>

     

    <li>

    <

     

    umbraco:Macro startingLevel="2" recurse="1" selectBranches="0" maxMenuDepth="4" ulBaseClass="" branchClass="branch" selectedClass="selected" forceNode="" expandChildren="0" forceHome="0" securityTrimming="0" Alias="[COG]Navigation" runat="server"></umbraco:Macro>

    </

     

    li></ul></div>

    <!-- END MENUE -->

    now, for example, i would much rather have the menue in a Content placeholder taken somewhere else from, so that i wouldnt have to update every template on this level in structure incase i make a change to my menue!

     

    also inside that "layout" content for content placeholder is

    <

     

    div class="middlecontainer">

     

    <h1><umbraco:Item field="pageName" runat="server"></umbraco:Item></h1>

     

    <p><umbraco:Item field="ingress" runat="server"></umbraco:Item></p>

     

    <p><umbraco:Item field="brdtext" runat="server"></umbraco:Item></p>

     

    <p class="articledivider"><b>Kontakt:</b><script language=javascript >noSpam("<umbraco:Item field="kontaktperson_epost" runat="server"></umbraco:Item>", "sub.su.se", "<umbraco:Item field="kontaktperson_Namn" runat="server"></umbraco:Item>");</script></p>

     

    <p><b>Publicerad:</b> <umbraco:Item field="createDate" formatAsDate="true" runat="server"></umbraco:Item></p>

     

    <p><b>Sidansvarig:</b><script language=javascript >noSpam("<umbraco:Item field="sidansvarig_alternativ_epost" runat="server"></umbraco:Item>", "sub.su.se", "<umbraco:Item field="sidansvarig_alternativ_namn" runat="server"></umbraco:Item>");</script></p>

     

    <p><b>Uppdaterad:</b><umbraco:Item field="updateDate" formatAsDate="true" runat="server"></umbraco:Item></p>

     

    </div>

    while i would MUCH rather have say..as an example

    <

     

    asp:Content ContentPlaceHolderId="MainContent" runat="server">

     

    <p><umbraco:Item field="ingress" runat="server"></umbraco:Item></p>

     

    <umbraco:Item field="brdtext" runat="server"></umbraco:Item>

    </

     

    asp:Content>

    but as this entire layout version ( 1 out of 3) is located inside a huge content area...i cant use other content areas inside of it?

     

    hope that helps so i might get an answer or i will have to rethink everything.

  • Ove Andersen 435 posts 1541 karma points c-trib
    Mar 09, 2011 @ 10:20
    Ove Andersen
    0

    I hope I understand you correctly.

    It is possible to have content areas inside other content areas. But changing the content inside a content area including it on a page, will "overwrite" the default content.

    So you can do like this:

    MasterPage1 - "MasterContent"
    <%@ Master Language="C#" MasterPageFile="/umbraco/masterpages/default.master" AutoEventWireup="true" %>
    <asp:ContentPlaceHolder ID="MasterTemplate" runat="server"/>
    MasterPage2 - "ContentMaster"
    <%@ Master Language="C#" MasterPageFile="/masterpages/MasterPage1.master" AutoEventWireup="true" %>
    <asp:Content ContentPlaceHolderID="MasterTemplate" runat="server">
    <asp:ContentPlaceHolder Id="Menu" runat="server">
    // Default content for the menu
    </asp:ContentPlaceHolder>
    <asp:ContentPlaceHolder Id="MainContent" runat="server">
    // Default content for maincontent
    </asp:ContentPlaceHolder>
    </asp:Content>
    MasterPage3 - "Article"
    <%@ Master Language="C#" MasterPageFile="/masterpages/MasterPage2.master" AutoEventWireup="true" %>
    <asp:Content ContentPlaceHolderID="MainContent" runat="server">
    // The content you put here will override the default content for this placeholder in MasterPage2
    </asp:Content>

    The first MasterPage is somewhat redundant if it doesn't contain anything else than a ContentPlaceHolder.

    I use MasterPage1 to set static stuff like the doctype declaration, the whole <head></head> part and then the "MasterTemplate" contentplaceholder is placed inside the <body></body> tags. The rest is like described over.

    Like this:

     

    <%@ Master Language="C#" MasterPageFile="/umbraco/masterpages/default.master" AutoEventWireup="true" %>
    <asp:Content id="Mastercontent" ContentPlaceHolderID="ContentPlaceHolderDefault" runat="server">
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Language" content="en">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title><umbraco:Item field="siteName" insertTextAfter=": " runat="server" recursive="true" /><umbraco:Item runat="server" field="pageName" /></title>
    <!-- Sitemaps and Feeds -->
    <!-- Favicon -->
    <!-- Stylesheets -->
    <!-- Scripts -->
    </head>
    <body>
    <div id="container">
    <form runat="server">
    <asp:ContentPlaceHolder ID="MasterTemplate" runat="server" />
    </form>
    </div>
    </body>
    </html> 
    </asp:content>

     

  • Martin 18 posts 73 karma points
    Mar 11, 2011 @ 10:47
    Martin
    0

    i can't get it to work thou....

    Heres the code, stripped out of markups.

      

    MASTER PAGE ( Master1.master)

    <%@ Master Language="C#" MasterPageFile="~/umbraco/masterpages/default.master" AutoEventWireup="true" %>
    <asp:Content ContentPlaceHolderID="ContentPlaceHolderDefault" runat="server">
    <asp:ContentPlaceHolder ID="layout" runat="server" />
    </asp:Content>

     

     

    LAYOUTPAGE ( 3col.master)

     

    <%

    @ Master Language="C#" MasterPageFile="~/masterpages/Master1.master" AutoEventWireup="true" %>
    <asp:Content ContentPlaceHolderID="layout" runat=server>
    <asp:ContentPlaceHolder ID="LeftMenue" runat="server" />
    </asp:Content>

     

    MENUE PAGE (leftmenue.master)

     

     

     

    <%@ Master Language="C#" MasterPageFile="~/masterpages/3col.master" AutoEventWireup="true" %>
    <asp:Content ContentPlaceHolderID="LeftMenue" runat=server>
    <

     

    umbraco:Macro startingLevel="2" recurse="1" selectBranches="1" maxMenuDepth="4" ulBaseClass="" branchClass="ParentSelect" selectedClass="selected" forceNode="" expandChildren="0" forceHome="0" securityTrimming="0" Alias="[COG]Navigation" runat="server"></umbraco:Macro>
    </asp:Content>

     as it is now i have to add the COG nav macro and settings on each template under the master template level...where i want the menue.

     

     

     

     

Please Sign in or register to post replies

Write your reply to:

Draft