Like regular components that can be defined for a page class using
Scrivito.provideComponent
, layout components are rendered when an instance of the class, i.e. a specific page is to be displayed byScrivito.CurrentPage
. However, if the page to be rendered has a path,Scrivito.CurrentPage
additionally renders the layout components of the ancestor pages, if present, beginning at the root object’s layout down to the layout of the current page. Only then, the actual page component, which can be provided optionally usingScrivito.provideComponent
, is rendered. Instead of providing such a page component, the page content can also be rendered from within the layout component. See below for an example.
This rendering sequence enables you to implement nested layouts with components specific to the page types and hierarchy levels involved. Since layout components, just like regular components for pages, may include editable content, you can, for example, provide editors with widgets (e.g. navigation widgets) that are aware of the structural environment of the current page.