3

After sitecore 8.2 upgrade 4 , we are not getting item language fallback value for item fields which are not shared , These items has value in en language and not in en-GB. But in the same scenario , we are getting value for the shared fields. We had made all three required setting as below.

1) We had set fallback language en for en-GB language.

enter image description here

2) In site definition also we had enable item language fallback setting as true. i.e "enableItemLanguageFallback=true".

3) And we also checked the "Enable Item Fallback" field on that particular item.

  • Could you check that all fields have checked “Enable Field Fullback” checkbox on field level? – Andrei Paliakou Oct 24 '17 at 18:35
  • Just to clear one thing, Shared is unrelated to Language Fallback. Language Fallback specifies that when a field is empty then it should get its value from the Fallback Language. Shared field means that all language versions share one value for a field, there is no fallback here. If you change the value in any language, all languages will be affected with this change. So your problem is simply Fallback is not working (regardless of the Shared Field value). – TamerM Nov 28 '17 at 9:04
3

If you want to enable Language Fallback you must add patch or this file must exist /App_Config/Include/Sitecore.LanguageFallback.config or any custom config that include the settings.

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
  <sitecore>
    <settings>
      <setting name="LanguageFieldFallback.AllowVaryFallbackSettingsPerLanguage">
        <patch:attribute name="value">false</patch:attribute>
      </setting>
    </settings>
    <sites>
      <!--Enable Item level language fallback - Allows a item to completely fall back to another language-->
      <!--Enable Field level language fallback - Allows control at the field level where only selected fields fall back to another language-->
      <site name="website">
        <patch:attribute name="enableItemLanguageFallback">true</patch:attribute>
        <patch:attribute name="enableFieldLanguageFallback">true</patch:attribute>
        <patch:attribute name="enforceVersionPresence">true</patch:attribute>
      </site>
      <site name="shell">
        <patch:attribute name="enableItemLanguageFallback">true</patch:attribute>
        <patch:attribute name="enableFieldLanguageFallback">true</patch:attribute>
      </site>
    </sites>
  </sitecore>
</configuration>

Also you should check the checkboxes on Template field level. Note that upon checking the 'Enable field level fallback' it is not necessary to manually tick this checkbox for each of the content node as this is a shared file under Advance section of Standard Fields.

enter image description here

You can verify that the language fallback is activated by checking the 'Enable Item Fallback' field in an item.

The value of this field gets inherited as any other field within the active language. This also means you can override this setting on items if needed.

enter image description here

I prepared aspx pages for enable language fallback.

Field Level:

<%@ Page Language="C#" AutoEventWireup="true" %>

<%@ Import Namespace="Sitecore" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Sitecore Template Field Level Lang Fall Back Setup</title>
</head>
<body>
    <%
        using (new Sitecore.SecurityModel.SecurityDisabler())
        {
            var db = Sitecore.Configuration.Factory.GetDatabase("master");

            // Field Template Fields
            var items = db.SelectItems("fast:/sitecore/templates/User Defined//*");

        foreach (var item in items)
        {
            item.Editing.BeginEdit();
            item.Fields["Enable Shared Language Fallback"].Value = "1";
            item.Fields["Enable Language Fallback"].Value = "1";
            item.Editing.EndEdit();
            Response.Write(item.Paths.FullPath + " - OK" + "<br/>");
        }
    }
%>

Item Level:

<%@ Page Language="C#" AutoEventWireup="true" %>

<%@ Import Namespace="Sitecore" %>
<%@ Import Namespace="Sitecore.Data.Items" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Sitecore Template Item Level Lang Fall Back Setup</title>
</head>
<body>
    <%
        using (new Sitecore.SecurityModel.SecurityDisabler())
        {
            var db = Sitecore.Configuration.Factory.GetDatabase("master");

        // Item Template Tempalte
        var items = db.SelectItems("fast:/sitecore/templates/User Defined//*");

        foreach (var item in items)
        {
            var standardValuesItem = item.Children.FirstOrDefault(x => x.Name == "__Standard Values");
            if (standardValuesItem != null)
            {
                if (standardValuesItem.Fields["__Enable item fallback"].Value != "1")
                {
                    standardValuesItem.Editing.BeginEdit();
                    standardValuesItem.Fields["__Enable item fallback"].Value = "1";
                    standardValuesItem.Editing.EndEdit();
                    Response.Write(standardValuesItem.Paths.FullPath + " - OK" + "<br/>");
                }
            }
            else
            {
                var standartValues = ((TemplateItem) item).CreateStandardValues();

                standartValues.Editing.BeginEdit();
                standartValues.Fields["__Enable item fallback"].Value = "1";
                standartValues.Editing.EndEdit();
                Response.Write(standartValues.Paths.FullPath + " - OK" + "<br/>");
            }
        }
    }
%>

  • Thanks guys for detail on language fallback, just have one more doubt that is it required to check shared field on template level for language fallback. Because i debug the code and found that our base template title field is not getting language fallback value and it is not shared . So do we have to also check enable item fallback on base template and also do we have to make that field shared ? – Sam Oct 26 '17 at 14:33
  • You shouldn't make field as shared. Just set enable item fallback and set enable field fallback. If you want I can provide aspx pages for enable fallback programmatically – Andrei Paliakou Oct 26 '17 at 15:37
  • Thanks Andrei, yes it would be really helpful for me if you share aspx pages, then I will try it from code as well. – Sam Oct 26 '17 at 18:04
  • I added aspx pages – Andrei Paliakou Oct 27 '17 at 7:39
  • Hi Andrei , i took some time to find-out what is exactly going wrong , because we have also use glass mapper v4 , but after some finding , came to know that it is not issue with glass mapper because , we have updated it as well and also checked. The exact issue is with sitecore 8.2 upgrade , we are not getting item language fallback value for the fields , which are not shared. For shared field it is working properly. I had verified setting many times , the same setup is working with sitecore 8.1 and it works for shared as well as non shared fields. So please guide on this. – Sam Oct 30 '17 at 13:56

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.