views:

255

answers:

3

How can I use the Server Side Includes module in IIS to include and process a ColdFusion file from a .htm file? I'm currently doing something like this in my html file:

<!--#include virtual="navmenu.cfm"-->

This includes the raw contents of the navmenu file. I need it to execute the ColdFusion code and return the output of that process rather than including the raw ColdFusion code.

This same syntax works properly in Apache.

A: 

If you are using a Coldfusion page it is:

 <cfinclude template="navmenu.cfm">

If you are using another type of page you will need to put that content in an IFRAME

<iframe src="navmenu.cfm"></iframe>

The question is if you have Coldfusion technology available on the server, why not change that page to a .cfm page and use the above example?

jarofclay
I may have been unclear. The file that needs to do the including is a .htm file, which requires the #include syntax and SSI module (I just edited the question to better reflect this). Your answer would work great if the base file was ColdFusion.
dadwithkids
+4  A: 

Are you just trying to avoid the CFM extension in the URL?

You can't use SSI to include a CFM files into a static HTM file. You can configure IIS to send HTM files to the CF server to be parsed. This would allow you to use CFINCLUDE inside any HTM file.

Alternately, you can use ajax from your HTM file and load the parsed CFM content into a DIV.

iKnowKungFoo
I would second this. Send the HTM file to CF, and use a regular cfinclude. Alternately AJAX, since SSI will just "copy/paste" the code into the file, meaning it will come out as source code and not be processed.
Andrew Backer
I am converting from a linux/apache server to a windows/iis server. Having CF server parse all the .htm files is not really a viable option for us. The ajax option would be somewhat tedious to implement. Is there really no way to do the equivalent processing in IIS?
dadwithkids
Not as far as I know. I'm more comfortable with Apache than IIS, but what as I understand it, having IIS send HTM files to the CF server is not very difficult. In fact, in order to not have the CF server process all those static HTM files, I know many developers that have IIS only process .HTML files so they can have a non-CFM extension that can still be dynamic.Here are instructions for having CF server parse HTML externsion with or without configuring IIS: http://www.pbell.com/index.cfm/2007/3/31/Processing-html-files-using-ColdFusion--on-a-Mac-or-a-PC
iKnowKungFoo
+1  A: 

If you can't make the top page appear to be a cfm to the outside have you thought about using the URL Rewrite Module for IIS? That way you could just make certain files cfms with some explicit htm to cfm rewrite rules but leave all others unprocessed. Beyond that I think there may not be an elegant answer since you are mixing static and dynamic content.

On your comment about ajax - personally I don't find anything tedious about using ajax but then again jquery spoils you...

 <div id='menuhere'></div>

 $.get('navmenu.cfm', function(data) {$('.menuhere').html(data); });

Accomplishes the same thing as the SSI plus (assuming jQuery is cached) you get faster main content page loads to boot.

kevink
I ended up going with this solution as it was the quickest way to accomplish what I needed. This is not the best solution for me though because the ColdFusion html I'm loading in is the page navigation. For others, please note that the big downside of this solution is that no search engines will get access to whatever is included via ajax, which in this case is my navigation.
dadwithkids