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
    Please specify sitecore and glass versions
    – josedbaez
    Commented Nov 2, 2016 at 16:14
  • Have you enabled item fallback, or field level fallback, or both?
    – jammykam
    Commented Nov 2, 2016 at 17:38
  • Just item fallback Commented Nov 2, 2016 at 18:10
  • This might be an issue with Glass, and the way it is inferring language for the linked lookup items. My suggestion would be to log an issue: github.com/mikeedwards83/Glass.Mapper/issues
    – jammykam
    Commented Nov 3, 2016 at 18:11
  • Glass gets the target item using the Language of the original item. github.com/mikeedwards83/Glass.Mapper/blob/master/Source/… I believe that in 8.1 this should be en-GB since the OriginalLanguage value would be en. However I would need to check. Commented Nov 4, 2016 at 7:12

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. Commented 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. Commented Nov 11, 2016 at 2:27

Your Answer

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

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