During the building of a website or a web application, usually it could be required to render different views with different layouts. Think about, for example, the lists and details of news made in this chapter.
The layout is managed by the $layout
property of Controller
; main
is the default value for this property.
Just set this property to change the layout file where to render the content of the view.
There are some important rules to write the value of the $layout
property:
A path alias (for example,
@app/views/layouts/main
).An absolute path (for example,
/main
) is where the layout value starts with a slash. The actual layout file will be looked for under the application layout path, which defaults to@app/views/layouts
.A relative path (for example,
main
) is where the actual layout file will be looked for under the context module's layout path, which defaults to theviews/layouts
directory under the module directory.The Boolean value false is where no layout will be...