【问题标题】:Glass mapper not mapping fallbacked fields in Sitecore 8.1Glass 映射器未映射 Sitecore 8.1 中的后备字段
【发布时间】:2016-08-10 11:56:11
【问题描述】:

当从 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; }
 }

谢谢!

【问题讨论】:

    标签: sitecore sitecore8 glass-mapper sitecore8.1


    【解决方案1】:

    您可以在返回模型时尝试使用 VersionCountDisabler 吗?

    var sitecoreContext = new SitecoreContext();
    using (new VersionCountDisabler())
    {
       Model1 = sitecoreContext.GetCurrentItem<Model>();
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-12-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-06-27
      • 1970-01-01
      • 2022-08-03
      相关资源
      最近更新 更多