allBlogsList

Sitecore MVC Image or Text within a Link Field renderer continued

On a recent project, I needed to make use of the FixLinkFieldTitle processor Niket Ashesh wrote about in his blog post Sitecore MVC Image or Text within Link Field renderer. However, I noticed inconsistent behavior between internal links compared to external links. This was something that garnered my attention.

When processing an external link, the Link Field processor worked exactly as expected. However, when processing an internal link, the Link Field processor was not rendering the link URL correctly. It turns out that the custom pipeline processor needed to be added a little bit further down in the pipeline.

Instead of adding the FixLinkFieldTitle processor after the GetLinkFieldValue processor.

<processor patch:after="*[@type='Sitecore.Pipelines.RenderField.GetLinkFieldValue, Sitecore.Kernel']" type="XCore.SitecoreExtensions.Pipelines.RenderField.FixLinkFieldTitle, XCore.SitecoreExtensions" />

It needed to be added after the GetInternalLinkFieldValue processor.

<processor patch:after="*[@type='Sitecore.Pipelines.RenderField.GetInternalLinkFieldValue, Sitecore.Kernel']" type="Aacn.SitecoreExtensions.Pipelines.RenderField.FixLinkFieldTitle, Aacn.SitecoreExtensions" />

Once that change was made, the Link Field processor performed as expected for both internal as well as external links.