Created
April 11, 2016 07:50
-
-
Save RyanABailey/d1b015bfde77051c353e1c013d8f0164 to your computer and use it in GitHub Desktop.
Sitecore Custom Item Resolver
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 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 | |
} | |
} | |
} |
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
<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