简体   繁体   English

如何在 Umbraco 8 中使用 DocumentType(模型)制作主布局模板?

[英]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我正在 umbraco 8 中创建一个网站,我有一个主布局模板,我已经为这个主布局添加了文档类型并在其中使用了 ImageCropper 现在我需要使用主布局模板中内容的图像集,怎么做,因为我在使用时遇到错误

@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.无法将源内容类型 Umbraco.Web.PublishedModels.HomePage 绑定到模型类型 Umbraco.Web.PublishedModels.Master。 Both view and content models are PureLive, with same version.视图和内容模型都是 PureLive,版本相同。 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:您还可以在不使用 ModelsBuilder 的情况下获取属性,如下所示:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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