Skip to content

View Helpers

includeContent()

includeContent() — returns string

Available in: controller Category: Miscellaneous Functions

Outputs the content for a specific section in a layout. Works together with contentFor() to define and then inject content into layouts. Typically used for head, sidebar, footer, or other pluggable layout sections. If the requested section hasn’t been defined, it will either return nothing or the provided defaultValue.

NameTypeRequiredDefaultDescription
namestringnobodyName of layout section to return content for.
defaultValuestringnoWhat to display as a default if the section is not defined.
1. In your view template, let's say `app/views/blog/post.cfm
contentFor(head='<meta name="robots" content="noindex,nofollow">');
contentFor(head='<meta name="author" content="wheelsdude@wheelsify.com">');

// In `app/views/layout.cfm`
<html>
	<head>
	    <title>My Site</title>
	    #includeContent("head")#
	</head>
	<body>
		<cfoutput>
			#includeContent()#
		</cfoutput>
	</body>
</html>