Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

cfincludes with URL parameters

New Here ,
May 14, 2009 May 14, 2009

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?

7.1K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
May 14, 2009 May 14, 2009

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:)!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
May 14, 2009 May 14, 2009

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
May 15, 2009 May 15, 2009
LATEST

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources