Search code examples
htmlcoldfusion

Including a ColdFusion file inside an HTML file


I have included numerous coldfusion and html files in CFM pages using the <cfinclude> tag. Now there is a tack reversal. I want to include a .CFM file in an .html file. (The html file will also be hosted on a ColdFusion server.)

Below is how my html looks. Please advise.

P.S.: I want to avoid using iframes.

<table border="0" width="750" cellspacing="0" cellpadding="0">
    ...
    <TD WIDTH=612 HEIGHT=418 COLSPAN=10 ROWSPAN=2 BGCOLOR=#131005>
        <img WIDTH="612" HEIGHT="418" src="images/slideshow.png">
        <!--- here is where I want to include the file --->
        <cfinclude template="slidemodule.cfm">
    </TD>

Solution

  • If you can't give the file a .CFM file extension, then you can have the ColdFusion server parse .HTML files as if they were .CFM files. This is the only way a CFINCLUDE will run in an HTML file.

    http://www.pbell.com/index.cfm/2007/3/31/Processing-html-files-using-ColdFusion--on-a-Mac-or-a-PC

    You'll have to edit your web.xml file and tell your web server what file extension will also be parsed by the CF server.

    Using this technique, if you leave .HTM files as static, non-parsed files, you can just name the file .HTM or .HTML to determine which can contain CFML.