Skip to content

Instantly share code, notes, and snippets.

@janhebnes
Created August 31, 2012 09:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save janhebnes/3550874 to your computer and use it in GitHub Desktop.
Save janhebnes/3550874 to your computer and use it in GitHub Desktop.
Sitecore CMS - Changes to the original Language Fallback module source for allowing fallback of layout deltas on a Shared layout fields - http://trac.sitecore.net/LanguageFallback/browser/Trunk/Sitecore.SharedSource.PartialLanguageFallback/Managers/Fallba
public static string ReadFallbackValue(Field field, Item item)
{
var fallbackItem = item.GetFallbackItem( MasterLanguage);
 
// makes 3 step renderings, currentitem -> fallback -> standard value
if (!TemplateManager.IsTemplate(item) && field.ID == Sitecore.FieldIDs.LayoutField && fallbackItem != null && fallbackItem.Versions.Count > 0 )
{
Field field1 = fallbackItem.Fields[field.ID];
if (!field1.ContainsStandardValue)
{
if (string.IsNullOrEmpty(field1.GetStandardValue()))
{
return field1.Value;
}
 
return XmlDeltas.ApplyDelta(field1.GetStandardValue(), field1.Value);
}
}
 
//return fallbackItem != null && fallbackItem.Versions.Count > 0 ? fallbackItem[field.ID] : null;
 
string fallbackValue = null;
 
if (fallbackItem != null && fallbackItem.Versions.Count > 0)
{
// There is a fallback item, lets get the value from that
return fallbackItem[field.ID];
}
else if (fallbackItem != null && fallbackItem.Template.StandardValues != null && item.Versions.Count > 0)
{
// there is no fallback item, and there is a version of me, get the fallback standardvalue
return fallbackItem.Template.StandardValues[field.ID];
}
 
return null;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment