You are viewing documentation for v1.1.x. Change

renderPage()

Description

Instructs the controller which view template and layout to render when it's finished processing the action. Note that when passing values for controller and/or action, this function does not load the actual action but rather just loads the corresponding view template.

Function Syntax

renderPage([ controller, action, template, layout, cache, returnAs, hideDebugInformation ])

Parameters

Parameter Type Required Default Description
controller string No [runtime expression] Controller to include the view page for.
action string No [runtime expression] Action to include the view page for.
template string No A specific template to render. Prefix with a leading slash / if you need to build a path from the root views folder.
layout any No The layout to wrap the content in. Prefix with a leading slash / if you need to build a path from the root views folder. Pass false to not load a layout at all.
cache any No Number of minutes to cache the content for.
returnAs string No Set to string to return the result instead of automatically sending it to the client.
hideDebugInformation boolean No false Set to true to hide the debug information at the end of the output. This is useful when you're testing XML output in an environment where the global setting for showDebugInformation is true.

Examples

<!--- Render a view page for a different action within the same controller --->
<cfset renderPage(action="edit")>

<!--- Render a view page for a different action within a different controller --->
<cfset renderPage(controller="blog", action="new")>

<!--- Another way to render the blog/new template from within a different controller --->
<cfset renderPage(template="/blog/new")>

<!--- Render the view page for the current action but without a layout and cache it for 60 minutes --->
<cfset renderPage(layout=false, cache=60)>

<!--- Load a layout from a different folder within `views` --->
<cfset renderPage(layout="/layouts/blog")>

<!--- Don't render the view immediately but rather return and store in a variable for further processing --->
<cfset myView = renderPage(returnAs="string")>