Sitecore Pipeline and Custom Processor

What is Pipeline?

Pipeline is series of step that is defined to show the sequence.

A pipeline is basically a method whose flow is defined using XML.

A pipeline consists of a sequence of Processor.  A processor is a .NET class that implements a method. When a pipeline is invoked, the processors are run in order.

Pipelines are defined in Sitecore.Config and in Sitecore patch files.

The following is an example of the pipeline that is responsible for rendering a page:

Adding Custom Processor

There were multiple scenario where you might have to create the custom Processor.

Generally on website you will see 404 message when Item not found, In that case you might have to display the custom page. Below is the step for doing.

Create a new config file and provide a name ErrorResolver.config.

In above configurations, I am using Patch Attribure to inject the custom process in HttpRequestBegin pipeline after the ItemResolver Processor.

pipeline
Error404Resolver.cs
using Sitecore.Pipelines.HttpRequest;

namespace MyProject.Sitecore.Commands
{
public class Error404 : HttpRequestProcessor
{
if (CoreSite.Context.Item == null)
{
CoreSite.Context.Item = s      Sitecore.Context.Database.GetItem.GetItem(“/sitecore/content/Error404”);
}
}
}

Above class help to attach the custom Sitecore item whenever the Error404 occurred.

References

http://sitecore-community.github.io/docs/pipelines-and-events/pipelines/

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.