Sitecore Pipelines

Pipelines are one of Sitecore’s essential integration concepts. They are used to extend existing functionality. Pipelines define a sequence of processor that implement different functions such as handling page requests, to uploading files and saving items through the UI. If you have a series of tasks, which need to be performed to accomplish a task, then a pipeline may be the way to go.

What is Pipelines?

Pipelines are used to control most of Sitecore’s functionality. Pipelines are defined in Web.config and in Sitecore patch files.

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

render-page-pipeline
Sitecore separates the pipelines into two groups: those defined within the /configuration/sitecore/pipelines and /configuration/sitecore/processors elements in the web.config file. In general, those defined within the /configuration/sitecore /processors define pipelines that operate for UI requests and can interact with the user. Those defined with the /configuration/sitecore/pipelines tend to define system processes.

What is processor?

Each step in pipeline is called a ‘processor’. The sequence of processors within a pipeline is defined in web.config file. Each Processor contains a unique operation and all these steps together create a pipeline.

A processor is a .NET class that implements a method. When a pipeline is invoked, the processors are run in order. Processes ranging from authentication to request handling to publishing to indexing are all controlled through pipelines.

Each processor in a pipeline contains a method named Process() that accepts a single argument and returns void. This method should return immediately if the processing context is not relevant to the processor. A processor can abort the pipeline, preventing Sitecore from invoking subsequent processors.

<pipelines /> define system process such as initialize Sitecore application, load content editor warning. <processors /> define UI process such as copy item, delete item, drag item and so on.

List of Sitecore Pipelines

Sitecore includes more than 140 pipelines.  Installing Sitecore modules also results in more pipelines being added.

The following is a list of some of the more commonly used pipelines.

<initialize> 

Runs when the IIS application pool is started. Processors handle initialization tasks that need to run once.

<httpRequestBegin> 

This pipeline handles the HTTP request. This includes tasks such as resolving the context item, device and presentation settings.

<httpRequestBegin> under configuration/sitecore/pipelines in sitecore.config, defines Sitecore context. By default there are 19 processors under <httpRequestBegin> pipeline but it may vary based on different modules you have installed in Sitecore.
For example: If you have installed Sitecore DMS then you will find 21 processors under <httpRequestBegin> pipeline.

<insertRenderings> – Determines the presentation components to include when rendering an item

<renderField> – Runs when the FieldRenderer is used to render a field value.

MVC-specific pipelines

The following table lists all of the Sitecore pipelines that are only used by MVC:

Pipeline Description
RequestBegin This is the first action of an MVC request after the request has been passed down from the main HttpRequest pipeline.

PageContext is created and assigned to the current thread.

If the request is a form post, the associated form handler (if any) is executed.

RequestEnd This is the last action of an MVC request. This pipeline is not currently used.
CreateController This pipeline is called by the SitecoreControllerFactoryto create a controller for the current route selected by the MVC request handler.

If the requested item (PageContext.Item) specifies a controller (in the __Controller Name field), this controller is instantiated and returned. Otherwise, an instance of the default SitecoreController is returned.

ActionExecuting This pipeline executes before an MVC controller action is executed. This pipeline is not currently used.
ActionExecuted This pipeline executes after an MVC controller action is executed. This pipeline is not currently used.
ResultExecuting This pipeline executes before an MVC result is executed. This pipeline is not currently used.
ResultExecuted This pipeline executes after an MVC result is executed. This pipeline is not currently used.
Exception This pipeline executes after the MVC runtime catches an unhandled exception. This pipeline is not currently used.

If you attach a custom processor to this pipeline, this processor should set the ExceptionContext.ExceptionHandledproperty on the ExceptionArgs object that is handed to the processor. Otherwise, Sitecore will do standard error handling.

GetPageItem This pipeline resolves the item that was requested using route information. If the item cannot be resolved from the route, Context.Item is used.
BuildPageDefinition This pipeline builds the initial PageDefinition by using the XML-based layout definition of the Renderings field on the page item.
GetPageRendering This pipeline selects the rendering to use as the root rendering of the page for creating the output of the current request.

Currently, the root rendering is selected based solely on the current device (PageContext.Device).

GetRenderer This pipeline transforms an abstract rendering definition (rendering) into an object that can render output back to the client (renderer).
GetModel This pipeline creates the model object to use when rendering an MVC view. This is typically a ASP.NET MVC 3 Razor view.

If the pipeline returns no model, the view receives an instance of EmptyModel. This triggers a meaningful error message if the .cshtml file contains the @model directive and therefore expects a model.

RenderPlaceholder This pipeline is called as part of the Html.Sitecore().Placeholder extension method. It handles nested placeholders, when applicable.

By default, the pipeline finds all renderings matching the specified placeholder name in the current PageDefinition and renders them. It only renders child renderings if the rendering explicitly renders them, typically by calling Html.Sitecore().Inner().

RenderRendering The pipeline renders the specified rendering. This pipeline handles caching and sets up the IRenderingContext for accessing source items of the renderings. This supports nested renderings.
Advertisements

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 )

Google+ photo

You are commenting using your Google+ 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 )

w

Connecting to %s