Skip to content

Instantly share code, notes, and snippets.

@jbreuer
Last active August 29, 2015 14:04
Show Gist options
  • Save jbreuer/5e00f21c70285f448124 to your computer and use it in GitHub Desktop.
Save jbreuer/5e00f21c70285f448124 to your computer and use it in GitHub Desktop.
Give the home node the parent url.
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