filters()
Description
Tells Wheels to run a function before an action is run or after an action has been run. You can also specify multiple functions and actions.
Function Syntax
filters(through [, type, only, except ])
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
through |
string |
Yes | |
Function(s) to execute before or after the action(s). |
type |
string |
No | before |
Whether to run the function(s) before or after the action(s). |
only |
string |
No | |
Pass in a list of action names (or one action name) to tell Wheels that the filter function(s) should only be run on these actions. |
except |
string |
No | |
Pass in a list of action names (or one action name) to tell Wheels that the filter function(s) should be run on all actions except the specified ones. |
Examples
<!--- Always execute `restrictAccess` before all actions in this controller --->
<cfset filters("restrictAccess")>
<!--- Always execute `isLoggedIn` and `checkIPAddress` (in that order) before all actions in this controller except the `home` and `login` actions --->
<cfset filters(through="isLoggedIn,checkIPAddress", except="home,login")>
