14

In Sitecore, under /sitecore/layouts, I see the following:

  • Layouts
  • Sublayouts
  • Renderings

What are these, and what makes them different? Are there any other types of layouts?

21

Layouts

  • Provide the outermost HTML structure of a page.
  • There is one layout (per device) per page.
  • Apply to WebForms (.aspx) and MVC (.cshtml)
  • Comprise of Layout definition item and aspx page (WebForms) or cshtml file (MVC)

Sublayouts

  • Provide inner HTML structure to a component or structuring element of a page.
  • Apply only to WebForms
  • Comprise of a definition item + .ascx control.
  • Can contain nested Sublayouts within their placeholders

Renderings

  • Provide inner HTML structure to a component or structuring element of a page.
  • Can be used with WebForms (if using XSLT) OR MVC
  • Sitecore MVC uses the following rendering sub-types:
    • Controller rendering: rendering definition item references a controller and action name
    • View rendering: rendering definition item references a view (cshtml file) and optionally a viewmodel (which in turn references a model type in code)
    • Item rendering: rendering definition item does not reference a controller or a view, instead it serves as a kind of 'placeholder'. The datasource item should have a rendering type associated with it via the __renderers field. Setting the datasource of an item rendering causes Sitecore to look at the datasource item itself to decide which rendering to use.
  • Comprise of a definition item + .xslt or .cshtml view
  • Can contain nested renderings (or sublayouts [1]) within their placeholders

[1] can only contain nested sublayout if xslt rendering within a WebForms solution

More information on MVC-specific aspects can be found here: http://www.matthewdresser.com/sitecore/sitecore-mvc-presentation-concepts

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.