</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?
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>
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
<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)
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)?
<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>
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.
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.
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?
Hi,
What is targeting the "ChildContent" place holder that you have setup? This would be called from another template by doing something like:
Does that make sense?
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">?
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:
edit: in the inserted code the line
should be
i forgot that i had beed playing around a bit.
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
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)
-- 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
Actually your code is incorrect.
These should be:
Rich
Yeah i should have it sorted.. but for some reason it just doesnt display.
As i said i have my master template which, via
calls (and should display) the relevant content from the child master template
but this doesnt work.. but thanks for the help guys.. i'll try to figure this out.
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
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:
rich
okay guys, here comes the code.
newMaster.master
my content masterpage, Contentpage2Columns.master
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:
appreciate any help you can give me.
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
You'll have to cut and paste the image link.
Can we *please* have an edit facility on these forums!
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
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
is working on a reply...