Skip to content

Instantly share code, notes, and snippets.

@RyanABailey
Created April 11, 2016 07:50
Show Gist options
  • Save RyanABailey/d1b015bfde77051c353e1c013d8f0164 to your computer and use it in GitHub Desktop.
Save RyanABailey/d1b015bfde77051c353e1c013d8f0164 to your computer and use it in GitHub Desktop.
Sitecore Custom Item Resolver
public class MyCustomResolver : HttpRequestProcessor
{
public override void Process(HttpRequestArgs args)
{
// Return if Sitecore has found the item
if (Context.Item != null || Context.Database == null || args.Url.ItemPath.Length == 0) return;
// If item not found
var itemPath = args.Url.ItemPath; // The requested item path
var context = Factory.GetDatabase("web");
var item = context.GetItem("/"); // Business logic here to find the new item
if (item != null)
{
Context.Item = item; // If the item is found return it
}
}
}
<processor type="Sitecore.Pipelines.HttpRequest.ItemResolver, Sitecore.Kernel"/>
<processor type="MyProject.MyCustomResolver , MyProject" />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment