Created
October 23, 2013 06:34
Using IContentFinder to get content outside of the main content tree in Umbraco 6.1 to replicate the behavior of the pipeline in v4 that allowed you to view content outside the main content tree by its assigned URL. Based on the Gist by Lee K.
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