View Helpers
includeLayout()
Signature
Section titled “Signature”includeLayout() — returns string
Available in: controller
Category: Miscellaneous Functions
Description
Section titled “Description”Includes the contents of another layout file. This is usually used to include a parent layout from within a child layout.
Parameters
Section titled “Parameters”| Name | Type | Required | Default | Description |
|---|---|---|---|---|
name | string | no | layout | Name of the layout file to include. |
Examples
Section titled “Examples”// 1. Include the default parent layout from within a child layout
// (looks for `app/views/layout.cfm` by default)
#includeLayout()#
// 2. Include a specific parent layout by path
// (looks for `app/views/layouts/application.cfm`)
#includeLayout("/layouts/application.cfm")#
// 3. Pass section content to the parent layout before including it
// Capture sidebar markup to make it available in the parent layout
<cfsavecontent variable="sidebar">
<nav>
#includePartial("categories")#
</nav>
</cfsavecontent>
<cfset contentFor(sidebar=sidebar)>
// Then pull in the parent layout that renders the sidebar via includeContent()
#includeLayout("/layouts/application.cfm")#