I have created a Master Template with my sites' pages' templates as children of it.
I can add content to the MasterTemplate like <h1>Site title</h1> or use @RenderSection("SectionName") but can I add fields?
I've included, for example, @Umbraco.Field("FieldName") but I can't work out how to add information to the field name. It doesn't appear in the content of the page that uses the Master Template.
You should be able to use @Umbraco.Field("FieldName") in your master template but should be aware of that the @Umbraco.Field is simply renders the contents of a field for the current content item.
I've added properties to document types, added them to the related templates with @Umbraco.Field("FieldName"), added content and then displayed them in the page.
For properties to be displayed in a Master Template, I've created a document type and linked it to the Master Template and then added these properties to the Master Template with @Umbraco.Field("FieldName") but they are not then displayed in the content of the page that uses the master template.
On Umbraco.tv http://umbraco.tv/videos/umbraco-v7/ you will find a video collection that shows the basic concepts of Umbraco, if you don´t already know that.
I think the Master Document Type is used to include properties in its documents type children. For instance, if I wanted to include a RTE property about the latest promotion on several pages I could use the Master Document Type to include in its child document types. This is nothing to do with Master Templates.
Let me turn the question on it head. What are the different ways of adding content to a Master Template like content for the header and the footer to appear on all the pages of the site?
Yes there is different ways of adding content to a Master Template like content for the header and the footer to appear on all the pages of the site. You could use XSLT or Razor I assume that you are using Umbraco 7 runing in the MVC mode, so therefore I will post some links on how to work with partial views or partial views macros.
On Umbraco TV you will also find a chapter on how working with Razor in Umbraco,
Adding content to a Maser Template
I'm using version 7.2.5 with MVC.
I have created a Master Template with my sites' pages' templates as children of it.
I can add content to the MasterTemplate like <h1>Site title</h1> or use @RenderSection("SectionName") but can I add fields?
I've included, for example, @Umbraco.Field("FieldName") but I can't work out how to add information to the field name. It doesn't appear in the content of the page that uses the Master Template.
Perhaps I have to use macros?
Your help would be much appreciated.
Thanking you in anticipation.
Roger
Hi Roger,
You should be able to use @Umbraco.Field("FieldName") in your master template but should be aware of that the @Umbraco.Field is simply renders the contents of a field for the current content item.
So the page that you are visited in the browser need to have the field, and it of course needs to have a value. Try to see this documentation about it https://our.umbraco.org/Documentation/Reference/Mvc/views#RenderingafieldwithUmbracoHelper
You could probably also get something from this videos about how to work with templates and master templates in Umbraco.
http://umbraco.tv/videos/umbraco-v7/implementor/fundamentals/templating/setting-up-our-first-template/
http://umbraco.tv/videos/umbraco-v7/implementor/fundamentals/templating/using-master-templates/
http://umbraco.tv/videos/umbraco-v7/implementor/fundamentals/templating/advanced-master-templates/
Hope this helps,
/Dennis
Thanks for your reply, Dennis.
I must be missing something here.
I've added properties to document types, added them to the related templates with @Umbraco.Field("FieldName"), added content and then displayed them in the page.
For properties to be displayed in a Master Template, I've created a document type and linked it to the Master Template and then added these properties to the Master Template with @Umbraco.Field("FieldName") but they are not then displayed in the content of the page that uses the master template.
Does that make sense?
Roger
Hi Roger,
Try to see the video about using a master document types, http://www.umbraco.tv/videos/umbraco-v7/implementor/fundamentals/document-types/master-document-type/ I Hope this helps to understand how Umbraco works.
On Umbraco.tv http://umbraco.tv/videos/umbraco-v7/ you will find a video collection that shows the basic concepts of Umbraco, if you don´t already know that.
Hope this helps,
/Dennis
I think the Master Document Type is used to include properties in its documents type children. For instance, if I wanted to include a RTE property about the latest promotion on several pages I could use the Master Document Type to include in its child document types. This is nothing to do with Master Templates.
Let me turn the question on it head. What are the different ways of adding content to a Master Template like content for the header and the footer to appear on all the pages of the site?
Hi Roger,
Yes there is different ways of adding content to a Master Template like content for the header and the footer to appear on all the pages of the site. You could use XSLT or Razor I assume that you are using Umbraco 7 runing in the MVC mode, so therefore I will post some links on how to work with partial views or partial views macros.
On Umbraco TV you will also find a chapter on how working with Razor in Umbraco,
http://umbraco.tv/videos/umbraco-v7/implementor/working-with-umbraco-data/razor-syntax/introduction-to-razor/
http://umbraco.tv/videos/umbraco-v7/implementor/working-with-umbraco-data/querying-umbraco-data-with-razor/
http://umbraco.tv/videos/umbraco-v7/implementor/working-with-umbraco-data/macros/
If you don´t subscribe yet, then you can find the different plans here http://umbraco.tv/plans-signup/
Hope this helps,
/Dennis
is working on a reply...