Page Controller 1.0 Documentation: Hello World

Page Controller Information

Blog Entries

Check Out AFF

Hello World

The Page Controller has two parts: The PageController.cfc that is to be extended by each page controller and the PageController.cfm that is to be called as a custom tag to invoke the page controller. Each page controller must be named the same as the associated page, except with a .cfc extension.

So, you have hello.cfm then the page controller for that page will be hello.cfc in the same folder. Each page controller should have a "loadData" method that returns a structure for variables to be used on the page. Here is an example of a page controller that simply sets a "Title" variable on the page:


<cfcomponent extends="PageController" output="no">

<cffunction name="loadData" access="public" returntype="struct" output="no">
	<cfset var vars = StructNew()>
	<cfset vars.Title = "Hello World">
	<cfreturn vars>





In this example, the hello.cfc was extending a PageController.cfc in the same directory (or in a CustomTags folder). Most likely you would want to put it in a centralized location and extend it from there. The hello.cfm isn't outputting a full HTML page, but that isn't needed to see how a Page Controller works.