Page Controller 1.0 Documentation: Filtering from URL Variables

Page Controller Information

Blog Entries

Check Out AFF

Filtering from URL Variables

The Page Controller can automatically create structure keys for use in filtering and adjust the title accordingly based on incoming URL variables. The "addURLFilter" method is provided for this use:



Here is a Page Controller for an order-list.cfm page:


<cfset loadExternalVars("Orders,Customers")>

<cffunction name="loadData" access="public" returntype="struct" output="no">
	<cfset var local = StructNew()>
	<cfset var vars = getDefaultVars("Orders","list")>
	<cfset addURLFilter(vars,"sFilters","customer","CustomerID",variables.Customers)>
	<cfreturn vars>


For our example, assume that variables.Customers.getLabelFieldValue(2) returns "Bob Smith".

You could call this page as order-list.cfm?customer=2 and the "sFilters" structure would have a sFilters["CustomerID"] = 2 and the title of the page would be "Orders for Bob Smith".