Hello everyone, a very new Umbraco user here. I've a situation like this. I want a header and footer section that can be edited by a content editor. And then I want to use them inside a master template, so that they are automatically added to all the child pages.
But I'm unable to think of a way to structure my document types to do this ? Any hint on how to do this, would be really helpful. Thanks.
You are trying to use ModelBuilder. The code I posted is using dynamic and typed IPublishedContent. Particularly I still do not use ModelBuider, for now I do the traditional way in Umbraco. Show your code to understand better.
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage<ContentModels.Site>
@using ContentModels = Umbraco.Web.PublishedContentModels;
@{
Layout = null;
var home = CurrentPage.Site();
}
Content from the site page
<h1>@home.gHeaderText</h1>
@RenderBody()
Here gHeader is a property for GlobalHeader text which I want to display on all the pages. I add a content node of type Site at root and get that 2nd error mentioned above.
I do not know how ModelBuider works, but from what I understand you should not put PublishedModels.Site as Model in Master Template. You must use PublishedModel in the context content template. For example, in the template of the node Site you can use:
Thanks Mario for your help. I'm very new to all these concepts like ModelBuilder and PublishedModel. I'll do some research and skim through documentations first. Hopefully I'll find some good resources to go through.
How to reuse content on different pages ?
Hello everyone, a very new Umbraco user here. I've a situation like this. I want a header and footer section that can be edited by a content editor. And then I want to use them inside a master template, so that they are automatically added to all the child pages.
But I'm unable to think of a way to structure my document types to do this ? Any hint on how to do this, would be really helpful. Thanks.
You can add the header and footer properties in the root site content and get them in the master template these ways:
will appear on all child pages of this master template
Thanks for your reply Mario. But when I try to use the child template I get this error:
"Cannot bind source content type Umbraco.Web.PublishedContentModels.Room to model content type Umbraco.Web.PublishedContentModels.Site"
And, when trying to use master layout doctype, I get this one:
The file "~/Views/Site.cshtml" cannot be requested directly because it calls the "RenderBody" method.
Any suggestion regarding this ?
You are trying to use ModelBuilder. The code I posted is using dynamic and typed IPublishedContent. Particularly I still do not use ModelBuider, for now I do the traditional way in Umbraco. Show your code to understand better.
See this link that explains in a simple way how to do. http://www.alexlindgren.com/archive/site-building-with-umbraco-7/
Here's my code for site layout:
Here gHeader is a property for GlobalHeader text which I want to display on all the pages. I add a content node of type Site at root and get that 2nd error mentioned above.
I do not know how ModelBuider works, but from what I understand you should not put PublishedModels.Site as Model in Master Template. You must use PublishedModel in the context content template. For example, in the template of the node Site you can use:
but not in the master template. Try only
Thanks Mario for your help. I'm very new to all these concepts like ModelBuilder and PublishedModel. I'll do some research and skim through documentations first. Hopefully I'll find some good resources to go through.
is working on a reply...