简体   繁体   中英

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?

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);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM