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; }
protected override string GetFallbackValue(FieldFallbackPipelineArgs args) { Assert.IsNotNull(args.Field, "Field is null"); TemplateFallbackFieldItem fallbackField = args.Field; string resultText = fallbackField.DefaultFallbackValue; MasterVariablesReplacer masterVariablesReplacer = Sitecore.Configuration.Factory.GetMasterVariablesReplacer(); if (masterVariablesReplacer != null) { resultText = masterVariablesReplacer.Replace(resultText, args.Field.Item); } return resultText; }
public void Process(FieldFallbackPipelineArgs args) { // If the processor isn't enabled for this field, then don't even run the processor. if (IsEnabledForField(args.Field)) { args.FallbackValue = GetFallbackValue(args); if (args.HasFallbackValue) { args.AbortPipeline(); } } }
protected override string GetFallbackValue(FieldFallbackPipelineArgs args) { Assert.IsNotNull(args.Field, "Field is null"); Item fallbackItem = GetFallbackItem(args.Field); // if we have an ancestor with the field... if (fallbackItem != null && fallbackItem.Fields[args.Field.ID] != null) { // get the value of the ancestor item. // Standard Values are an acceptable value! return fallbackItem.Fields[args.Field.ID].GetValueSafe(true, false, false); } return null; }
protected override string GetFallbackValue(FieldFallbackPipelineArgs args) { Assert.IsNotNull(args.Field, "Field is null"); if (IsEnabledForField(args.Field)) { Item fallbackItem = GetFallbackItem(args.Field); if (fallbackItem != null) { // Get field's value from the fallback item return fallbackItem.Fields[args.Field.ID].GetValueSafe(true, true, EnableNestedFallback); } } return null; }
protected override string GetFallbackValue(FieldFallbackPipelineArgs args) { Assert.IsNotNull(args.Field, "Field is null"); Item masterItem = GetMasterItem(args.Field); string fieldValue = null; if (masterItem != null) { // Get the value of the field, from the master item, so we can translate it string translateMe = masterItem.Fields[args.Field.ID].GetValueSafe(true, false, EnableNestedFallback); // Call the translation service fieldValue = TranslationService.Translate(translateMe, _masterLanguage.CultureInfo, args.Field.Language.CultureInfo); } return fieldValue; }
/// <summary> /// Gets the fallback value. /// </summary> /// <param name="field">The field.</param> /// <returns></returns> public virtual string GetFallbackValue(Field field) { Assert.ArgumentNotNull(field, "field"); Item item = field.Item; Assert.ArgumentNotNull(item, "item"); Logger.Debug(">> GetFallbackValue - s:{0} db:{1} i:{2} f:{3}", Sitecore.Context.GetSiteName(), item.Database.Name, item.ID, field.Name); Logger.PushIndent(); string value = null; try { // test cache first value = Cache.GetFallbackValue(item, field); // we have a cached value.. return it. if (value != null) { Logger.Debug("Value found in the cache"); return value; } // Call the fieldFallback pipeline var pipelineArgs = new FieldFallbackPipelineArgs(field); Sitecore.Pipelines.CorePipeline.Run("fieldFallback", pipelineArgs); // if the args has a value, then one of the processors fell back to something if (pipelineArgs.HasFallbackValue) { Logger.Debug("Fallback Found"); // put it in the cache Cache.AddFallbackValues(item, field, pipelineArgs.FallbackValue); return pipelineArgs.FallbackValue; } Logger.Debug("No fallback"); return null; } finally { Logger.PopIndent(); Logger.Debug("<< GetFallbackValue"); } }
protected abstract string GetFallbackValue(FieldFallbackPipelineArgs args);