Reputation: 225
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>
Upvotes: 0
Views: 3350
Reputation: 1
You can use server side includes (SSI) in IIS, Apache, and likely other web servers to include a .cfm/.cfml or any other file. CF will render the html content of the file, the web server will include it, and the .html page will render properly. This method won't incur the extra overhead of having CF needlessly parse HTML pages.
In Apache, it looks like this (need mod_include):
(non-CF-file includes work the same)or with URL parameters:
Upvotes: 0
Reputation: 224
As far as I know, if you included your HTML file into the page using
<cfinclude template="yourHTMLFile.html" />
it will be treated and parsed as CFM file. That's only if included the HTML file not with a direct request.
Check Bennadel post: http://www.bennadel.com/blog/250-CFInclude-Templates-Are-Parsed-Regardless-Of-File-Type.htm
Also as others suggested Ajax call with JQuery will do the job easily.
Upvotes: 1
Reputation: 14859
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.
Upvotes: 3
Reputation: 152
I had to do something similar recently. Try playing with Jquery and Ajax calling a cfc as a web service and display the results in a tag. Hope this helps!
This should help you get started: http://www.raymondcamden.com/index.cfm/2011/12/21/ColdFusion--jQuery-example
Upvotes: 0
Reputation: 582
I suggest using an AJAX call to render the CFM file, and insert the rendered HTML in your main HTML file.
Upvotes: 1