Reputation: 11120
I have a page with a name of
summary.cfm
inside of it:
<cfinclude template="view/totals.cfm>
view/totals.cfm
inside of it:
variables.grandTotalHTML = invoke("viewtotals, "doSummary", {...});
view/viewtotals.cfc
inside of it
<cfmodule template="summarytemplate.cfm" ...>
<!--- database is not passed in here --->
view/summarytemplate.cfm
Inside of it we have
param attributes.database = session.database;
...
databaseoverride = attributes.database;
...
<cfquery name="qData">
SELECT *
FROM [#variables.databaseoverride#]
...
</cfquery>
Now question
I don't know where the databaseoverride is coming from.
viewtotals.cfc
?Upvotes: 1
Views: 344
Reputation: 6550
(Too long for comments)
Just to elaborate on Dan's answer:
summary.cfm
VARIABLES
scope with the included template, "view/totals.cfm"view/totals.cfm
VARIABLES
scope with the parent template, "summary.cfm"view/viewTotals.cfc
Its VARIABLES
scope is not shared with any of the calling templates (summary.cfm and view/totals.cfm)
Its VARIABLES
are accessible to the cfmodule - through the CALLER
scope (as are the function's local
and arguments
scopes)
view/summaryTemplate.cfm
VARIABLES
scope with anyone. CALLER
scope. ( The REQUEST
scope is accessible to all of the scripts above.)
Upvotes: 1
Reputation: 4694
The variables scope at the module level is local to the module. An unscoped variable in a module is in variables scope.
This line
databaseoverride = attributes.database;
is equivalent to
variables.databaseoverride = attributes.database;
so is setting the value used here
<cfquery name="qData">
SELECT *
FROM [#variables.databaseoverride#]
...
</cfquery>
Upvotes: 2