Sure, but it is right out of the manual. Here is my
onRequest:
<CFFUNCTION NAME="onRequest" RETURNTYPE="void">
<CFARGUMENT NAME="targetPage" TYPE="string"
REQUIRED="true"/>
<CFSET DSN="#This.DSN#">
<CFINCLUDE TEMPLATE="#Arguments.targetPage#">
</CFFUNCTION>
The only other thing I did was to configure IIS with virtual
directories. The above code works fine when the CFM files are in
InetPub (and accesssed at
http://www.testserver.com).
When I put the files in a virtual directory,c alled "v20" and
access as
http://www.testserver.com/v20.,
the following error occurs.
Could not find the included template /v20/index.cfm.
Note: If you wish to use an absolute template path (e.g.
TEMPLATE="/mypath/index.cfm") with CFINCLUDE then you must create a
mapping for the path using the ColdFusion Administrator. Using
relative paths (e.g. TEMPLATE="index.cfm" or
TEMPLATE="../index.cfm") does not require the creation of any
special mappings. It is therefore recommended that you use relative
paths with CFINCLUDE whenever possible.
The error occurred in C:\v20\Application.cfc: line 166
164 : <CFARGUMENT NAME="targetPage" TYPE="string"
REQUIRED="true"/>
165 : <CFSET DSN="#This.DSN#">
166 : <CFINCLUDE TEMPLATE="#Arguments.targetPage#">
167 : </CFFUNCTION>
168 :
When I log the value of Arguments.targetPage I get
/v20/index.cfm. Why isn't it just /index.cfm? If I create a
mapping, it will work, but in my onRequestStart I look for several
special pages and have to add "/v20" to the page path. I'd prefer
not to do that, since the virtual directory may vary.