在项目的后备语言版本中映射来自 Sitecore 的项目时,有没有办法让 Glass 映射器使用非共享字段。
Glass 只能将共享字段映射到我的模型。我的 Sitecore 项目具有英语值,而德语则回落到英语。当我询问该项目的德语版本时,我得到一个仅具有共享字段值的项目。
我正在使用 glass mapper v4 和 Sitecore 8.1。
我的 Application_BeginRequest 方法如下所示:
protected void Application_BeginRequest(object sender, EventArgs e)
{
Sitecore.Context.Items["Disable"] = new VersionCountDisabler();
}
我的类看起来像这样:
[SitecoreType(AutoMap = true)]
public class CustomModel
{
[SitecoreField]
public virtual string Title { get; set; }
[SitecoreField]
public virtual string Description { get; set; }
[SitecoreField("Another field")]
public virtual string AnotherField{ get; set; }
}
谢谢!
最佳答案
您可以在返回模型时尝试使用 VersionCountDisabler 吗?
var sitecoreContext = new SitecoreContext();
using (new VersionCountDisabler())
{
Model1 = sitecoreContext.GetCurrentItem<Model>();
}
关于sitecore - Glass 映射器未映射 Sitecore 8.1 中的后备字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38872773/