Copied to clipboard

Flag this post as spam?

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


  • Thorbjørn Andersen 7 posts 27 karma points
    Oct 13, 2009 @ 15:42
    Thorbjørn Andersen
    0

    Help with templates?

    Hi all,

     

    im not sure if this is the right place for this post but here goes.

     

    i have just installed umbraco with Creative Website Starter pack yesterday and have been playing with ever since.

    I think that i have the basics down but i must be missing something here.

    In my own new master template i have this code for the body:

        <body>   
            <div id="mainArea">   
                <form id="Form1" runat="server">
                               
                    <!-- BODY-->
                    <div id="body">
                        <div class="clearfix">
                            <div id="sideBar" class="left">
                                <!-- XSLT Macro - Navi -->
                                <umbraco:Macro Alias="CWS_Navi" runat="server"></umbraco:Macro>
                               
                                <!-- Insert default "SideBar" markup here -->
                                <asp:ContentPlaceHolder Id="SideBarContent" runat="server" />
                                                                     
                            </div>
                            <div id="Child Content">
                                <p>this is a test 2</p>
                            <!-- Insert default "ChildContent" markup here -->
                                <asp:ContentPlaceHolder Id="ChildContent" runat="server" />
                            </div>
                                              
                        </div>    
                                   
                    </div>
                   
                </form>      
            </div>      
        </body>

     

    And for some reason the content in the placeholder "ChildContent" wont display. The <p> in the same div displays just fine, so this leads me to conclude that i must have some syntax wrong. Now i have been comparing my code to the code for the CWS_Master template, and i just cant seem to find any significant differences.

     

    Maybe someone here can point me in the right dirrection?

  • Nik Wahlberg 639 posts 1237 karma points MVP
    Oct 13, 2009 @ 15:48
    Nik Wahlberg
    0

    Hi,

    What is targeting the "ChildContent" place holder that you have setup? This would be called from another template by doing something like:

    <asp:content ID="Content1" ContentPlaceHolderId="ChildContent" runat="server">
        <!-- insert a field from a document type or other markup -->
        <umbraco:Item field="bodyText" runat="server"></umbraco:Item>
    </asp:content>

    Does that make sense?

  • Thorbjørn Andersen 7 posts 27 karma points
    Oct 13, 2009 @ 15:59
    Thorbjørn Andersen
    0

    Yeah it does.

    I thought it was enough to have the default contentplaceholder on the outside of your <html>.....</html>?

    maybe i need an extra contentplaceholder inside my <div id="Child Content">?

  • Thorbjørn Andersen 7 posts 27 karma points
    Oct 13, 2009 @ 16:05
    Thorbjørn Andersen
    0

    hmm.. nope not that..

    okay i have my newMaster.master which contains the above code, from my original post

    and i have a child template to that which contains the following:

     

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

    <asp:content ContentPlaceHolderId="ChildContent2" runat="server">
    <div id="childcontent">
    <p>This is a test</p>
    <table width="100%" height="100%">
    <tr>
    <td>
    <div id="col1">
    <umbraco:Item field="siteBodyCol1" runat="server"></umbraco:Item>>
    </div>
    </td>
    <td width="1px">
    </td>
    <td>
    <div id="col2">
    <umbraco:Item field="siteBodyCol2" runat="server"></umbraco:Item>>
    </div>
    </td>
    </tr>
    </table>
    </div>



    </asp:content>
  • Thorbjørn Andersen 7 posts 27 karma points
    Oct 13, 2009 @ 16:07
    Thorbjørn Andersen
    0

    edit: in the inserted code the line

    <asp:content ContentPlaceHolderId="ChildContent2" runat="server">

    should be

    <asp:content ContentPlaceHolderId="ChildContent" runat="server">

     

    i forgot that i had beed playing around a bit.

  • Rich Green 2246 posts 4008 karma points
    Oct 13, 2009 @ 16:22
    Rich Green
    0

    Seems like you may have it sorted? I was just typing out this response, it may help your understanding anyway:

    The following line in your "Master Template" will not render anything on it's own

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

    All this is doing is acting as a 'Placeholder' for some content that can be added via another Master Template  which is a child of this template (as described by Nik above).

    So your Master Templates layout might look like this

    - Master Template (with <asp:ContentPlaceHolder Id="ChildContent" runat="server" />)

    -- Child Master Template (with the following)

    <asp:content ID="Content1" ContentPlaceHolderId="ChildContent" runat="server">
        <!-- insert a field from a document type or other markup -->
        <umbraco:Item field="bodyText" runat="server"></umbraco:Item>
    </asp:content> 

    -- Child Master Template 2 (with the following)

    <asp:content ID="Content1" ContentPlaceHolderId="ChildContent" runat="server">
        This text here will be placed in your master template where the <asp:ContentPlaceHolder Id="ChildContent" runat="server" /> is
    </asp:content> 

     

    The child templates are only needed if the content is going to vary from page to page whilst the main content "Master Template" stays the same.

    Usually the Master Template will contain Main Navigation, Sub Navigation & Site Footer etc. 

    The Child Templates will contain different content (for example, Home page and  Content pages)

    If you're keen to learn Umbraco I'd recommend subscribing to Umbraco.tv, even if for just a month. The video 'Using Master Templates' http://umbraco.org/documentation/videos/for-site-builders/templating/using-master-templates would show you what you need to know.

    Hope that makes sense.

    Rich

     

  • Rich Green 2246 posts 4008 karma points
    Oct 13, 2009 @ 16:29
    Rich Green
    0

    Actually your code is incorrect.

    <asp:content ContentPlaceHolderId="ChildContent" runat="server">

    These should be:

    <asp:content id="Any_Unique_ID" ContentPlaceHolderId="ChildContent" runat="server">

    Rich

  • Thorbjørn Andersen 7 posts 27 karma points
    Oct 13, 2009 @ 16:33
    Thorbjørn Andersen
    0

     

    Yeah i should have it sorted.. but for some reason it just doesnt display.

    As i said i have my master template which, via

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

    calls (and should display) the relevant content from the child master template

    <asp:content ContentPlaceHolderId="ChildContent" runat="server">
           
    <div id="childcontent">
           
    <p>This is a test</p>
           
    <table width="100%" height="100%">
                   
    <tr>
                           
    <td>
                                   
    <div id="col1">
                                           
    <umbraco:Item field="siteBodyCol1" runat="server"></umbraco:Item>>
                                   
    </div>
                           
    </td>
                           
    <td width="1px">
                           
    </td>
                           
    <td>
                                   
    <div id="col2">
                                           
    <umbraco:Item field="siteBodyCol2" runat="server"></umbraco:Item>>
                                   
    </div>
                           
    </td>
                   
    </tr>
           
    </table>
           
    </div>
           
           
           
    </asp:content>

    but this doesnt work.. but thanks for the help guys.. i'll try to figure this out.

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Oct 13, 2009 @ 16:56
    Dirk De Grave
    0

    Just a stupid question: Did you set the template correctly for the page you're trying to view (you've not accidentally set the master as template instead of the child)?

     

    /Dirk

  • Rich Green 2246 posts 4008 karma points
    Oct 13, 2009 @ 16:56
    Rich Green
    0

     

    I suggest you paste all off your 2 templates code in (including the top line page declaration).

    Also still think you still need to add an id on this line:

    <asp:content ContentPlaceHolderId="ChildContent" runat="server">

    rich

     

  • Thorbjørn Andersen 7 posts 27 karma points
    Oct 14, 2009 @ 09:42
    Thorbjørn Andersen
    0

    okay guys, here comes the code.

     

    newMaster.master

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

    <asp:Content 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>
    <title>
    <umbraco:Macro Alias="CWS_PageTitle" runat="server"></umbraco:Macro>
    </title>

    <!-- CSS -->
    <link href="/CSS/Stylestest.css" rel="stylesheet" type="text/css" />
    <link href="/CSS/Reset.css" rel="stylesheet" type="text/css" />

    <!-- XSLT Search CSS -->
    <link href="/CSS/XSLTsearch.css" rel="stylesheet" type="text/css" />

    <!--[if IE]>
    <link href="/CSS/ie.css" rel="stylesheet" type="text/css" />
    <![endif]-->

    <!--[if IE 6]>
    <link href="/CSS/ie6.css" rel="stylesheet" type="text/css" />
    <![endif]-->

    <!-- sIFR CSS -->
    <link href="/CSS/sifr.css" rel="stylesheet" type="text/css" />

    <!-- JS -->
    <script src="/Scripts/jquery-1.3.1.min.js" type="text/javascript"></script>
    <script src="/Scripts/script.js" type="text/javascript"></script>

    <!-- sIFR JS -->
    <script src="/Scripts/sIFR/sifr.js" type="text/javascript"></script>
    <script src="/Scripts/sIFR/sifr-config.js" type="text/javascript"></script>

    <!-- Meta Data -->
    <meta name="description" content="<umbraco:Item field='metaDescription' recursive='true' runat='server'></umbraco:Item>" />
    <meta name="keywords" content="<umbraco:Item field='metaKeywords' recursive='true' runat='server'></umbraco:Item>" />


    </head>
    <body>
    <div id="mainArea">
    <form id="Form1" runat="server">

    <!-- BODY-->
    <div id="body">
    <div class="clearfix">
    <div id="sideBar" class="left">
    <!-- XSLT Macro - Navi -->
    <umbraco:Macro Alias="CWS_Navi" runat="server"></umbraco:Macro>

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

    </div>
    <div id="Child Content">
    <p>this is a test 2</p>
    <!-- Insert default "ChildContent" markup here -->
    <asp:ContentPlaceHolder Id="ChildContent" runat="server" />
    </div>

    </div>

    </div>

    </form>
    </div>
    </body>
    </html>
    </asp:Content>

     

    my content masterpage, Contentpage2Columns.master

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

    <asp:content id="SidebarC" ContentPlaceHolderId="SideBarContent" runat="server">
    <div class="secondaryNav">
    <h3>News &amp; Events</h3>
    <!-- XSLT Macro - News Events Sub Navi -->
    <umbraco:Macro Alias="CWS_NewsEventsSubNavi" runat="server"></umbraco:Macro>
    </div>
    </asp:content>

    <asp:content id="ChildC" ContentPlaceHolderId="ChildContent" runat="server">
    <div id="childcontent 2">
    <p>This is a test</p>
    </div>
    </asp:content>

     

    now my logic says that my newMaster.master basically defines how the page looks. IE it contains my <body> tag and somewhere in this tag there is a contentplaceholder which should call my Contentpage2Columns.master which defines the contetn to display instead of the contentplaceholder. But this doesnt work for some reason.

    The html code that is generated is this:

     


    <!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>
    <title>
    Your logo/name - Frontpage
    </title>

    <!-- CSS -->
    <link href="/CSS/Stylestest.css" rel="stylesheet" type="text/css" />
    <link href="/CSS/Reset.css" rel="stylesheet" type="text/css" />

    <!-- XSLT Search CSS -->
    <link href="/CSS/XSLTsearch.css" rel="stylesheet" type="text/css" />

    <!--[if IE]>
    <link href="/CSS/ie.css" rel="stylesheet" type="text/css" />
    <![endif]-->


    <!--[if IE 6]>
    <link href="/CSS/ie6.css" rel="stylesheet" type="text/css" />
    <![endif]-->


    <!-- sIFR CSS -->
    <link href="/CSS/sifr.css" rel="stylesheet" type="text/css" />

    <!-- JS -->
    <script src="/Scripts/jquery-1.3.1.min.js" type="text/javascript"></script>
    <script src="/Scripts/script.js" type="text/javascript"></script>

    <!-- sIFR JS -->
    <script src="/Scripts/sIFR/sifr.js" type="text/javascript"></script>
    <script src="/Scripts/sIFR/sifr-config.js" type="text/javascript"></script>

    <!-- Meta Data -->
    <meta name="description" content="" />
    <meta name="keywords" content="these are meta tags" />


    </head>
    <body>
    <div id="mainArea">
    <form method="post" action="/frontpage.aspx?" id="aspnetForm">
    <div>
    <input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUENTM4MWRkks66YS6pfYefgwYc42upiDUWoSY=" />
    </div>


    <!-- BODY-->
    <div id="body">
    <div class="clearfix">
    <div id="sideBar" class="left">
    <!-- XSLT Macro - Navi -->
    <ul id="navi"><li><a href="/home.aspx">Home</a></li><li><a href="/about.aspx">About</a></li><li><a href="/content.aspx">Content</a></li><li><a href="/gallery.aspx">Gallery</a></li><li><a href="/news-and-events.aspx">News and Events</a></li><li><a href="/contact.aspx">Contact</a></li><li class="&#xA; selected&#xA; "><a href="/frontpage.aspx">Frontpage</a></li></ul>

    <!-- Insert default "SideBar" markup here -->


    </div>
    <div id="Child Content">
    <p>this is a test 2</p>
    <!-- Insert default "ChildContent" markup here -->

    </div>

    </div>

    </div>

    </form>
    </div>
    </body>
    </html>

     

     

    appreciate any help you can give me.

  • Rich Green 2246 posts 4008 karma points
    Oct 14, 2009 @ 11:44
    Rich Green
    0

    Hi Thorbjørn,

    Your templates look fine.

    I think your problem is something to do with as  Dirk says.

    Go into 'Content' and select the piece of content that has the problem,there is a drop down box named "Template", what is this set to?  

    It should be set to the name of your "ContentPage2.ColumnsMaster" template.

    In this example below it should be set to "Child Content"

    Hope that helps

    Rich

  • Rich Green 2246 posts 4008 karma points
    Oct 14, 2009 @ 11:46
    Rich Green
    0

    You'll have to cut and paste the image link.

    Can we *please* have an edit facility on these forums!

  • Thorbjørn Andersen 7 posts 27 karma points
    Oct 14, 2009 @ 11:58
    Thorbjørn Andersen
    0

    hey Rich,

     

    Thanks man, you got me on the right track.

    I, as you suggested, went to "Content"->content item with problem to see what template was used. It was actually on the correct template but, just for the sake of it, i swicthed to another and then back again. That Solved it for me.

     

    Thanks again

  • Nik Wahlberg 639 posts 1237 karma points MVP
    Oct 15, 2009 @ 03:32
    Nik Wahlberg
    0

    In some cases, when making changes to document types and/or templates it is wise to re-publish the entire site or at least the page that you're working on. This is especially true is you have XMLCache on.

    Glad you got it solved.

    -- Nik

Please Sign in or register to post replies

Write your reply to:

Draft