Friday, May 4, 2012

Sitecore customization using pipelines

A pipeline consists of a number of processors arranged in sequence to process a common set of parameters. If I have a series of tasks, which need to be performed to accomplish a task, then a pipeline may be the way to go.
Instead of passing to each processor an arguments object containing these parameters, the pipeline class itself exposes properties representing the parameters.
Sitecore pipelines also allow an object to pass through each step. This object can be manipulated by any of the steps and passed through to the next step until the end is reached and the object can be used by whatever executed the pipeline in the first place.
In configuration file, you will be able to see numbers of pipelines, which is default from sitecore. You can create your own custom code and add pipeline to execute that code.

Pipeline contains parameter ‘type’, which contains information about class and assembly as shown in snapshot.

UI customization using pipelines
Each step in pipeline is called a ‘processor’. Pipeline call the ‘Process’ method from class. Whatever functionality you want to achieve can be written in ‘Process’ method.

For Example:
In this scenario, Pipeline class is inheriting ‘HttpRequestProcessor’ and overriding its Process method to achieve some functionality.

Now code has been written, we have to add pipeline in ‘web.config’ so it could execute. We have added our custom pipeline next to step, where we want to it be executed.

So with just a few lines of code and configuration we can consume benefits of pipeline architecture and perform our custom actions.

Have a great day and enjoy coding !!