-
-
Save Vrijdagonline/50c4029f86e67394c8f4 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 Umbraco.Core; | |
using Umbraco.Web.Routing; | |
namespace Website.ContentHelper | |
{ | |
public class ContentFinder : ApplicationEventHandler | |
{ | |
protected override void ApplicationStarting(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext) | |
{ | |
ContentFinderResolver.Current.InsertTypeBefore<ContentFinderByNotFoundHandlers, ContentFinderCommonPages>(); | |
base.ApplicationStarting(umbracoApplication, applicationContext); | |
} | |
} | |
public class ContentFinderCommonPages : IContentFinder | |
{ | |
public bool TryFindContent(PublishedContentRequest contentRequest) | |
{ | |
if (contentRequest != null) | |
{ | |
var path = contentRequest.Uri.GetAbsolutePathDecoded(); | |
var node = contentRequest.RoutingContext.UmbracoContext.ContentCache.GetByRoute(path); | |
contentRequest.PublishedContent = node; | |
} | |
return contentRequest.PublishedContent != null; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment