We have just recently implemented a solution for this, to handle links to a specific template (Modal) differently.
We created a custom renderField pipeline processor like the following:
namespace Pipelines
{
public class RenderModalLink
{
public void Process(RenderFieldArgs args)
{
Assert.ArgumentNotNull(args, "args");
if (Sitecore.Context.Site.DisplayMode == Sitecore.Sites.DisplayMode.Edit)
return;
var field = Sitecore.Data.Fields.FieldTypeManager.GetField(args.GetField());
// Is it a linkField
if (field is LinkField)
{
// Explicit cast required for some reason
LinkField linkField = (LinkField) field;
// Check if link is
if (linkField.LinkType.ToLower() == "internal")
{
// Check if field has a value
if (linkField.TargetItem == null)
return;
// Check if target item derives modal template (Synthesis)
var modal = linkField.TargetItem.As<IModalItem>();
if (modal != null)
{
// Add your custom parameters (HTML attributes) here
args.Parameters.Add("data-modal", linkField.GetFriendlyUrl());
args.Parameters.Add("href", "javascript:void(0);");
}
}
}
}
}
}
and patched it in after the SetParameters processor:
<renderField>
<processor type="Pipelines.RenderModalLink" patch:after="processor[@type='Sitecore.Pipelines.RenderField.SetParameters, Sitecore.Kernel']"/>
</renderField>