The FieldRenderer Control (Sitecore.Web.UI.WebControls.FieldRenderer) has a method called OverrideFieldValue that takes a string and is supposed to be shown instead of the real fields value, but it doesn't work.

It seems a fix would be to add in a new pipline that accounts for this preset value.

Here's the code:

public class GetOverriddenFieldValue
{
// Methods
public void Process(RenderFieldArgs args)
{
Assert.ArgumentNotNull(args, "args");

if (!string.IsNullOrEmpty(args.FieldValue))
args.Result.FirstPart = args.FieldValue;
else
args.Result.FirstPart = args.Item[args.FieldName];
}
}

You then need to drop this in the Pipline in the web.config file so that we can modify the value on the way out.

Look for the following node:

<processor type="Sitecore.Pipelines.RenderField.AddBeforeAndAfterValues, Sitecore.Kernel" />

Now add the following above that:

<processor type="Your.Namespace.GetOverriddenFieldValue, Your.Assembly" />

The bug has been logged with Sitecore so hopefully they release an official patch.

Comments (1) -

Alexey Rusakov

Sean,

The method is designed to substitute the actual plain field value with a runtime value, that might not yet be saved to a Sitecore item.

So using the OverrideFieldValue would make FieldRenderer function _as if_ Sitecore field contained that value. But it doesn't mean that it will be exactly what is displayed by the control.

Good catch on the bug. To fix it I would (and I will) modify the GetFieldValue processor so that it is aware of overriden value, instead of adding a new one later on.

Thanks for the report.

Comments are closed