protected override string GetFallbackValue(FieldFallbackPipelineArgs args) { Assert.IsNotNull(args.Field, "Field is null"); FallbackItem item = args.Field.Item; // Get the fields that this field should fallback to FieldFallback.Processors.Data.Items.FallbackItem.Setting setting = item.GetFallbackFields(args.Field); if (setting != null) { foreach (Field f in setting.SourceFields) { // get the value of the field // Standard Values are an acceptable value string val = f.GetValueSafe(true, false, EnableNestedFallback); if (val != null) { if (setting.TruncateText) { return(TruncateText(val, setting.ClipAt.Value, setting.UseEllipsis)); } else { return(val); } } } } return(null); }
public override void RemoveItemField(Item item, ID fieldID) { // With the LateralFieldFallbackProcessor, we need to clear that cache of a field that references this field too. FallbackItem fieldItem = item; if (fieldItem != null && fieldItem.HasLateralFallback) { List <ID> fieldsThatFallbackToMe = fieldItem.GetFieldsThatFallbackTo(item.Fields[fieldID]).ToList(); foreach (ID v in fieldsThatFallbackToMe) { Remove(GetFieldKey(item, v)); } } if (ClearChildEntries) { // we need to clear all child items that have this field // get cache keys for all items in this subtree List <string> keys = base.InnerCache.GetCacheKeys().Cast <string>().ToList(); string sfieldID = fieldID.ToString(); foreach (string key in keys) { // if this key contains the field, then clear it if (key.StartsWith(GetGeneralItemKeyPrefix(item)) && key.Contains(sfieldID)) { base.Remove(key); } } } else { base.Remove(GetFieldKey(item, fieldID)); } }
protected override bool IsEnabledForField(Field field) { if (field.ID == FallbackItem.FallbackFields) { return(false); } FallbackItem item = field.Item; return(item.DoesFieldHaveLateralFallback(field)); }