Created
July 21, 2016 09:17
-
-
Save Adamsimsy/4c4af66a53d3b7ba2ebef5a46c067ca7 to your computer and use it in GitHub Desktop.
Sitecore custom link provider example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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