Skip to content

Does Mach II have any "reserved" variable names when I create my views?

thofrey edited this page Jul 23, 2013 · 2 revisions

Yes. When Mach-II displays your views, it does it in the ViewContext.displayView() method. Specific variables already exist in the method when your view file is included. This can cause inconsistent behavior in your views if variable name conflicts occur or if you do not scope your variables (i.e. prefix them with the scope name like request or variables).

The following is the list of variable conflicts that currently exist in the 1.6.0 version of the framework:

Variable Name Scopes
append arguments.append or *unqualified append
contentKey arguments.contentKey or unqualified contentKey
contentArg arguments.contentArg or unqualified contentArg
resultArg arguments.resultArg or unqualified resultArg
event arguments.event, request.event or unqualified event
viewContent unqualified viewContent (it is a local variable in the method)
viewName arguments.viewName or unqualified viewName
viewPath unqualified viewPath (it is a local variable in the method)
appManager variables.appManager
propertyManager variables.propertyManager

We recommended and best practice suggests that you explicitly scope all variables inside your views (in addition to everywhere else) as this reduces the possibility of "reserved" variable name conflicts. Therefore, if you specify variables.append in your view, it would not conflict with the already defined arguments.append variable.

Unqualified means you are not directly referencing a specific scope when working with a variable.

Local means the variables was defined with var inside a CFC.

Back to FAQs

Clone this wiki locally