Skip to content

Instantly share code, notes, and snippets.

@Adamsimsy
Created July 21, 2016 09:17
Show Gist options
  • Save Adamsimsy/4c4af66a53d3b7ba2ebef5a46c067ca7 to your computer and use it in GitHub Desktop.
Save Adamsimsy/4c4af66a53d3b7ba2ebef5a46c067ca7 to your computer and use it in GitHub Desktop.
Sitecore custom link provider example
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Sitecore.Data.Items;
using Sitecore.Links;
namespace Sitemap.Custom
{
public class CustomLinkProvider : LinkProvider
{
public override string GetItemUrl(Item item, UrlOptions options)
{
var url = base.GetItemUrl(item, options);
//Example customisation which lowercases all URLs
if (!string.IsNullOrEmpty(url))
return url.ToLower();
return url;
}
}
}
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<linkManager>
<providers>
<add name="sitecore">
<patch:attribute name="type">Sitemap.Custom.CustomLinkProvider,Sitemap.Custom</patch:attribute>
</add>
</providers>
</linkManager>
</sitecore>
</configuration>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment