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
-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.

  • 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. – Dylan Young Nov 3 '16 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. – Varun Nehra Nov 11 '16 at 2:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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