Skip to content

Miscellaneous

contentFor()

contentFor() — returns any

Used to store a section’s output for rendering within a layout. This content store acts as a stack, so you can store multiple pieces of content for a given section.

NameTypeRequiredDefaultDescription
positionanyyeslastThe position in the section’s stack where you want the content placed. Valid values are first, last, or the numeric position.
overwriteanyyesfalseWhether or not to overwrite any of the content. Valid values are false, true, or all.
<!--- In your view --->
<cfsavecontent variable="mySidebar">
<h1>My Sidebar Text</h1>
</cfsavecontent>
<cfset contentFor(sidebar=mySidebar)>

<!--- In your layout --->
<html>
<head>
    <title>My Site</title>
</head>
<body>

<cfoutput>
#includeContent("sidebar")#

#includeContent()#
</cfoutput>

</body>
</html>