Copy link to clipboard
Copied
Is it possible to use cfincludes with a querystring??
I am new to coldfusion and would like to reuse code but keep receiving an error?
ex: <cfinclude template="some.cfm?find=myvalue" >
Whenever I try this, I get an error "Can not find included template"
Is there a work around or a Administrative setup I need to perform?
Copy link to clipboard
Copied
I think you'd be better off with cflocation and adding your URL params. Or, making your include a custom tag, so you can pass it parameters but don't think you can send URL params to cfinclude (I coudl be wrong there:)!
Copy link to clipboard
Copied
Not with <cfinclude...> CFInclude in a file system include. You are litterly includeing one file inside another file and CFML treats it as if the two files where really the same code file.
If you want to pass parameters into your code you need to go with a newer code reuse feature. <cfinclude...> is that first and oldest dating back to CF2.
Next up the line would be custom tags which allow you to pass in parameters in the form of <cf_myCustomTag aParam="aValue" bParam="bValue">
These can also be called with the <cfmodule...> tag.
Next comes the User Define Function (UDF) Where you can write resuable functions.
After that comes ColdFusion Components (CFC) where you can create resuable objects with mutliple functions.
Copy link to clipboard
Copied
Although I agree that either a UDF, cfmodule or component function would be the best bet, you could use the cfinclude but set the variable beforehand for it to be included:
<cfset yourVar = 'something' />
<cfinclude template="your_template_file.cfm" />
and in the included file use the 'yourVar' variable.