Copied to clipboard

Flag this post as spam?

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


  • Sean 141 posts 179 karma points
    Feb 09, 2011 @ 03:18
    Sean
    0

    Changing the default master page

    Hi There,

    I have the following below created by default everytime I create a new template. I want to create my own content items and reference a different template. What is the best approach on how to do this?

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

    Thanks in advance for your answer.

    Sean

  • Jan Skovgaard 11280 posts 23678 karma points MVP 10x admin c-trib
    Feb 09, 2011 @ 06:21
    Jan Skovgaard
    0

    Hi Sean

    This line is default and must be in the template otherwise I will nok work.

    What other template do you wish to reference?

    If you have a Master template where you have all of your default html elements you can create a template that inherits from the Master template. Let's call i frontpage. Here you write the code for the frontpage template. If you wish for another template to inherit from the frontpage template you can choose that on the specific template.

    The above stuff is just something default set on templates on the "first" level so to speak. If you create a template that must inherit from another template.

    For instance I have a page with two templates. A template, which I have named "Master".

    The content of my master template looks like this.

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

    <asp:Content ContentPlaceHolderID="ContentPlaceHolderDefault" runat="server">
     
    <!doctype html>  


    <html>

    <head>
      <meta charset="utf-8">

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

      <link rel="shortcut icon" href="/favicon.ico">
      <link rel="apple-touch-icon" href="/apple-touch-icon.png">


      <link rel="stylesheet" href="/css/style.css?v=2">
     
      <script src="/scripts/core/modernizr-1.6.min.js"></script>
      
    </head>

    <body>

      <div id="container">
        <div id="header">
          <h1><umbraco:Item field="slogan" runat="server"></umbraco:Item></h1>
        </div>
        

    <asp:ContentPlaceHolder Id="HovedeIndhold" runat="server">
      <!-- Insert default "MainContent" markup here -->
    </asp:ContentPlaceHolder>

        
        <div id="footer">
          <h3>About the page</h3>
          <p>Text....</p>
        </div>
      </div> <!--! end of #container -->
      
    </body>
    </html>
      
    </asp:Content>


    Then I have a page called "Frontpage" that looks like this and inherits from my master template above

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


    <asp:Content ContentPlaceHolderId="HovedeIndhold" runat="server">
        <div id="main">
          <h2><umbraco:Item field="header" runat="server"></umbraco:Item></h2>
          <umbraco:Item field="bodyText" runat="server"></umbraco:Item>
        </div>
    </asp:Content>

    Notice the path in the "MasterPageFile" on my frontpage template - it refers to my master template called "Master". If I had chosen to give it another name like "Default" the path would have reffered to "Default.master" instead.

    I hope this makes sense for you?

    Otherwise I suggest you install the "Creative website starter" package and study how templates are structured in this package.

    /Jan

  • Sean 141 posts 179 karma points
    Feb 10, 2011 @ 02:16
    Sean
    0

    Hi Jan,

    Thanks for the reply. I'm still getting my head around it. I tried to use the default master page and add a content item into it, as soon as I made a reference in my template to that content item I receieved the parese error "content level controls should be top level controls etc".

    So, my question is. Where does umbraco store the details to use this default.master? is it in a config file somewhere? Am I able to create a custom master and then reference it and have it used everytime I create a new template?

    Thanks for your help on this.

     

  • Jan Skovgaard 11280 posts 23678 karma points MVP 10x admin c-trib
    Feb 10, 2011 @ 07:41
    Jan Skovgaard
    0

    Hi Sean

    what does your templates look like? I gues it would be a bit easier to help you out if you can post the code that makes them up. Or perhaps just some screendumps.

    Umbraco knows which templates to use by the settings you have made on the document types.

    I don't know if you have noticed but when you create a document type, then there is a checkbox that is prechecked that says "create a template for this document type". Then in the "info" tab on the created document type you can see a section called "Allowed templates". Here you can choose, what templates should be allowed for a certain document type.

    And benetah you can select the default template. It's the default template that is being used when you create content nodes in the content section.

    I hope this makes thing more clear for you :-)

    /Jan

  • Rich Green 2246 posts 4008 karma points
    Feb 10, 2011 @ 07:50
    Rich Green
    1

    Sean,

    I guess you're using Visual Studio to edit / add your templates?

    It might be easier to use the Umbraco UI to create the master templates initially, as this automatically deals with ContentPlaceHolders and nesting.

    Then you can just edit them in Visual Studio as usual.

    Rich

  • Sean 141 posts 179 karma points
    Feb 11, 2011 @ 05:56
    Sean
    0

    Hi Guys,

    Thank you for replying to me. I have installed the business starter kit now to get my head around it. I had a completely blank install of the CMS initially, now I realise this was a mistake.

    I'll definitely use VS 2010 to make changes to the templates after they are created. I downloaded the visual studio project template and that seems to have helped me a lot with this.

    Thanks again.

Please Sign in or register to post replies

Write your reply to:

Draft