Sitecore has an interesting nomenclature for many terms describing components on the front-end and back-end of the CMS. One area I’d like to focus is the set of presentation components displayed on the front-end of the site. The page is broken down into several layers, the outermost being the page itself. The shell of any given page is a layout which in plain ASP.NET speak is represented by a standard Web Form, an .aspx file. The purpose of a layout is to create a shell that other sub-components of the page can get applied to. Think of a layout as a blueprint or framework for the page. Once Sitecore placeholders are added to a layout, many sub-components can be added to the page. These sub-components go by the umbrella term renderings.
Types of Renderings
Rendering is an umbrella term for the following components:
- Sublayout
- XSLT Rendering
- Web Control
Each of these rendering types has its own pros and cons and requires different coding styles to actually render content to the front-end of the site.
Sublayout
A sublayout is a Sitecore wrapper around a Web User Control, an .ascx in plain ASP.NET. Sublayouts are defined in Sitecore under /sitecore/content/layouts/sublayouts. Each sublayout definition contains a field for the path to the ASCX file. It also has additional default fields for DataSource, Parameters, and Caching options.
XSLT Rendering
An XSLT Rendering should not be confused with the umbrella term “rendering.” An XSLT rendering is like a sublayout in that its a wrapper around an existing ASP.NET component. In this case, an XSL Transformation.
Web Control
The last main type of rendering is a Web Control. A web control most closely related to a Server Control in ASP.NET. The rendered code from a web control is written in C# so web control are best used for components that require small amount of mark-up. Web Controls are powerful in that a developer can define additional Sitecore caching settings in the code. Web Controls are referenced by a namespace and assembly, so they must be compiled into a external DLL as opposed to a ASCX or XSLT.
Choices…
As you can see, as a developer, you have some choices on what types of rendering to use. I personally like to use Sublayouts almost exclusively because they’re flexible enough that I can write plenty of front-end HTML and can write all of my code-behind in C#. I generally stay away from XSLT unless I’m doing breadcrumbs, which Sitecore has a module for in the Shared Source repository. Web Controls seem to be useful if you want to create your own controls that don’t have a lot of HTML to be rendered. I see this being useful for small pieces of data that you need to massage before rendering to the page.
Could you please explain with a simple example or suggest link to know more about it, as I am dot net developer and new to sitecore.
Thanks