Reputation: 51
Is there a way to make Glass mapper work with non-shared fields when mapping items from Sitecore in a fallbacked langauge version of the item.
Glass is able to map only shared fields to my model. My Sitecore item has values in English and the German language falls back to English. When i ask for the German version of the item, I get back an item which has values only for the shared fields.
I am using glass mapper v4 and Sitecore 8.1.
My Application_BeginRequest method looks like this:
protected void Application_BeginRequest(object sender, EventArgs e)
{
Sitecore.Context.Items["Disable"] = new VersionCountDisabler();
}
and my class looks like this:
[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; }
}
Thanks!
Upvotes: 2
Views: 235
Reputation: 4118
Can you try to use VersionCountDisabler when you return your model?
var sitecoreContext = new SitecoreContext();
using (new VersionCountDisabler())
{
Model1 = sitecoreContext.GetCurrentItem<Model>();
}
Upvotes: 2