Skip to content

View Helpers

contentFor()

contentFor() — returns void

Available in: controller Category: Miscellaneous Functions

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
positionanynolastThe position in the section’s stack where you want the content placed. Valid values are first, last, or the numeric position.
overwriteanynofalseWhether 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>