Skip to content

Miscellaneous

usesLayout()

usesLayout() — returns any

Used within a controller’s init() function to specify controller- or action-specific layouts.

NameTypeRequiredDefaultDescription
templatestringyesName of the layout template or function name you want to use.
ajaxstringyesName of the layout template you want to use for AJAX requests.
exceptstringyesList of actions that should not get the layout.
onlystringyesList of actions that should only get the layout.
useDefaultbooleanyestrueWhen specifying conditions or a function, pass true to use the default layout.cfm if none of the conditions are met.
// We want this layout to be used as the default throughout the // entire controller, except for the `myAjax` action. usesLayout(template="myLayout", except="myAjax"); // Use a custom layout for these actions but use the default // `layout.cfm` for the rest. usesLayout(template="myLayout", only="termsOfService,shippingPolicy"); // Define a custom function to decide which layout to display. // // The `setLayout` function should return the name of the layout // to use or `true` to use the default one. usesLayout("setLayout");