6

This is for Sitecore 7.5 update-2 version.

We are using Item-level Language Fallback and everything works fine except this piece gives error every time except when in Page Editor mode.

item.Axes.SelectSingleItem('ancestor::*[@@templateid='GUID']//*[@@templateid='GUID']')

Above code returns NULL object when trying to fetch item in language version which it doesn't exist. Since we have Item-level Language Fallback configured I'm unable to understand why this doesn't fallback when using Sitecore query.

Anyone has any idea on this appreciated or did you faced same issue anytime?

  • How have you configured fallback? There were a few ways for 7.5 update-2 but not out the box? That got introduced in one of the 8 versions if I am correct. – Anicho Oct 3 '16 at 16:39
  • @Anicho We are using Item-level Language Fallback module. In download sections its mentioned as Language Fallback Item Provider Version 1.0.0 which gives file LanguageFallbackItemProvider100.zip that one. It has only one way to configure since it has only one .config and one field on system language item. – Harsh Baid Oct 3 '16 at 16:54
3

Root cause was - Item existed in EN version and when trying to preview in other language it should fallback to EN. Now twist here was EN version had publishing restrictions so effectively item didn't existed in any language versions which somehow gives error, from Item-level Language Fallback module, in page when trying to use preview mode.

I have fixed this issue by modifying the Item-level Language Fallback module's source.

I have downloaded module source from Sitecore marketplace. Recompiled module source with modified class as below..

public class LanguageFallbackItemProvider : ItemProvider
{

   protected override Item GetItem(ID itemId, Language language, Version version, Database database)
   {
        ... some code ...

        Item fallback = GetItem(itemId, fallbackLanguage, Version.Latest, database);

        /* FIX START - TO CHECK FALLBACK ITEM IS NULL */
        if (fallback == null)
        {
            return item;
        }
        /* FIX END - TO CHECK FALLBACK ITEM IS NULL */

        var stubData = new ItemData(fallback.InnerData.Definition, item.Language, item.Version, fallback.InnerData.Fields);

        ... some code ...
   }
}

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.