ColdFusion cfinclude variable passing

By admin | September 10, 2009

I just ran into an issue when i needed to pass a variable into a template i had called using <cfinclude>.

Coldfusion will error if you try and pass a variable within the include tag Eg. <cfinclude template=”mypage.cfm?myvariable=1″>

To get around this all you need to do is pass in the variable before the include tag, appended with URL..

Eg.
<cfset URL.myvariable = 1>
<cfinclude template=”mypage.cfm”>

Now mypage.cfm will grab the URL.myvariable and go about business as usual.

  • Share/Save/Bookmark

Topics: Coldfusion |

Comments