Last active
August 29, 2015 14:04
-
-
Save jbreuer/5e00f21c70285f448124 to your computer and use it in GitHub Desktop.
Give the home node the parent 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
public class HomeUrlProvider : DefaultUrlProvider | |
{ | |
public override string GetUrl(UmbracoContext umbracoContext, int id, Uri current, UrlProviderMode mode) | |
{ | |
var content = umbracoContext.ContentCache.GetById(id); | |
if (content.DocumentTypeAlias == "Home" && content.Parent != null) | |
{ | |
return base.GetUrl(umbracoContext, content.Parent.Id, current, mode); | |
} | |
return base.GetUrl(umbracoContext, id, current, mode); | |
} | |
} | |
/* | |
Register the HomeUrlProvider on ApplicationStarting | |
*/ | |
UrlProviderResolver.Current.InsertType<HomeUrlProvider>(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment