Search code examples
c#umbracoumbraco8

How to make a Master Layout Template with A DocumentType (Model) in Umbraco 8?


I am creating a website in umbraco 8 in this I have a master layout template and I have added the document type for this master layout and used a ImageCropper in it now I need to use the Image set from the content in the master layout template, How to do that as I am getting error when I use the

@inherits Umbraco.Web.Mvc.UmbracoViewPage<ContentModels.Master>

in the master layout template I get the error

Cannot bind source content type Umbraco.Web.PublishedModels.HomePage to model type Umbraco.Web.PublishedModels.Master. Both view and content models are PureLive, with same version. The application is in an unstable state and should be restarted. What am I doing wrong here?


Solution

  • Normally, what I do, I'd put all global properties on like a "settings"-node or on the homepage node and then in my Master template, I can do the following:

    var home = new Homepage(Model.Content.Site());
    var image = home.Image;
    

    You can also get properties without using the ModelsBuilder, like this:

    var image = Model.Content.GetPropertyValue<IPublishedContent>(recursive: true);