I have a rich text field that has certain tokens ({{alt}} and {{title}}) for embedded images in the HTML. I extended the Sitecore.Pipelines.RenderField.GetFieldValue processor so that when a page is rendered on the front end, the processor will replace those tokens with the alt and title field values from the media item. Unfortunately my custom processor only processes a certain set of items (specifically WFFM fields), it does not process my Body field which has the tokens, even though I know the page I am browsing is rendering that field (the code run on the layout is @Html.Sitecore().Field("Body") which means it should get processed by the pipeline, correct?)
I also tried the GetTextFieldValue and GetMemoFieldValue processors but the same items were processed. Looking for some guidance as to specifically which fields are supposed to get processed by this pipeline.
Here is my Process() function:
public void Process(RenderFieldArgs args)
{
Assert.ArgumentNotNull(args, "args");
Assert.ArgumentNotNull(args.Item, "args.Item");
Assert.ArgumentNotNull(args.GetField(), "args.GetField()");
if (args.Item.Database == Database.GetDatabase("web"))
{
if (args.GetField().Value.Contains("{{alt}}"))
{
args.GetField().Value = ReplaceAltToken(args.GetField().Value);
}
if (args.GetField().Value.Contains("{{title}}"))
{
args.GetField().Value = ReplaceTitleToken(args.GetField().Value);
}
if (args.GetField().Name == "Body")
{
// Since we're rendering the body field differently we need to expand dynamic links
args.Item.Editing.BeginEdit();
args.GetField().Value = Sitecore.Links.LinkManager.ExpandDynamicLinks(args.GetField().Value);
args.Item.Editing.EndEdit();
}
}
}
My config include file:
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<pipelines>
<renderField>
<processor
type="[Redacted].Processor.RenderField.GetFieldValueExtended, [Redacted].Processor"
patch:after="processor[@type='Sitecore.Pipelines.RenderField.GetFieldValue, Sitecore.Kernel']" />
</renderField>
</pipelines>
</sitecore>
webdatabase, are you checking this on CD server or CM server? - jammykamAttempt to retrieve context object of type 'Sitecore.Mvc.Presentation.PageContext' from empty stack.- Paul