3

I have two templates that look like the following:

Article

  • Title : Single Line
  • Categories : Multilist
    • Pulls in Another Item that provides a level of taxonomy to these articles.

Category

  • Title : Single Line
  • Description : Multiline
  • Image : Image

So the issue is that we have a Article where the language context on the page is en-GB, anything on that page that has items with a version in en-GB should pull from that language version. If it doesn't exist in that version it would fall back to en language (default language on the site). That all works correctly except when I have a property in Glass Mapper.

So if I'm on that page and the language context is en-GB, but the article falls back (correctly to en) but there is an en-GB version of the Category which is a property of Glass Model Article. Instead of pulling the en-GB version based on the context of the page, it'll just pull the en version because the Article fell back to that language.

Is there a way to fix this in Glass?


Version Information

  • Sitecore 8.1-2
  • Glass Mapper: 4.0.5.54
7

1 Answer 1

-1

I think this is more of an ItemProvider issue than a GlassMapper issue. You may need to write a custom ItemProvider and override the GetItem methods. Although I haven't worked with the LanguageFallback feature provided in Sitecore 8.1, this is what I had to do working with LanguageFallback module before Sitecore released it's official LanguageFallback with 8.1.

2
  • I'm not totally convinced that is true. So if we weren't using Glass, and instead working with the Item API directly, in this example pulling the articles field "category" would just contain Id's, so at some point something in glass must be converting those ids into items/types. Nov 3, 2016 at 1:48
  • @DylanYoung - If you look at the ResolveItem method (Glass.Mapper.Sc.Configuration.SitecoreTypeConfiguration) that loads the lookup field values, you will see that it eventually calls the good old Content API to fetch the item (Database.GetItem()).There is no magic way GlassMapper converts ItemIds to Items. It's all done via Content API, which is why I suggested you look at modifying the ItemProvider itself. Nov 11, 2016 at 2:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.