I have overwritten Tridion.ContentDelivery.Web.UI.ComponentLink to customize the link resolution.
public class ComponentLink : Tridion.ContentDelivery.Web.UI.ComponentLink
{
/// <summary>
/// Overwritten render method to resolve links of News pages
/// </summary>
/// <param name="writer"></param>
protected override void Render(HtmlTextWriter writer)
{
using (Tridion.ContentDelivery.Web.Linking.ComponentLink compLink = new Tridion.ContentDelivery.Web.Linking.ComponentLink(new Tridion.ContentDelivery.Web.Utilities.TcmUri(ComponentUri).PublicationId))
{
Tridion.ContentDelivery.Web.Linking.Link link = compLink.GetLink(PageUri, ComponentUri, TemplateUri, LinkAttributes, "", TextOnFail, AddAnchor);
if (!link.IsResolved)
{
Utility.LogEvent("Within First Condition");
if (Utility.IsNewsComponent(ComponentUri))
{
string linkString = string.Empty;
string newsBaseURL = ConfigurationManager.AppSettings["NewsBaseURL"].ToString();
int firstindex = ComponentUri.IndexOf('-', 0) + 1;
string componentid = ComponentUri.Substring(firstindex, ComponentUri.Length - (firstindex));
if (string.IsNullOrEmpty(LinkText))
{
linkString = string.Format(@" <a target=""_self"" title=""Read more here"" href=""{0}?id={1}"" class=""labelledIcon iconRight hidden-xs"">
Read more here", newsBaseURL, componentid);
LinkText = string.Format(@"<span class=""icon-arrow_right""></span>");
}
else
{
linkString = string.Format(@" <a href=""{0}?id={1}"" target=""_self"" >", newsBaseURL, componentid);
}
writer.Write(linkString);
writer.Write(LinkText);
this.RenderChildren(writer);
writer.Write("</a>");
}
else if (TextOnFail)
{
writer.Write(LinkText);
this.RenderChildren(writer);
}
}
else
{
string linkString = link.ToString();
int index = linkString.IndexOf("</a>");
if (index > 0)
{
linkString = linkString.Substring(0, index);
}
writer.Write(linkString);
writer.Write(LinkText);
this.RenderChildren(writer);
writer.Write("</a>");
}
}
}
}
Then I am trying to register the new DLL in web.config as:
Old entry:
<add tagPrefix="tridion" namespace="Tridion.ContentDelivery.Web.UI" assembly="Tridion.ContentDelivery" />
New entry
<add tagPrefix="tridion" namespace="Tridion.Extensions.ContentDelivery.Web.UI" assembly="TorkCustomLinkResolver" />
But doing this disables some of the existing functionalist that are based on other classes of Tridion.ContentDelivery.Web.UI.
like ComponentPresentation.
Please advice the correct procedure to use the extended Tridion.ContentDelivery.Web.UI.ComponentLink
class.